<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/*
<span class='line'>  2</span>  * Copyright (C) 2008, 2009, 2010 Mihai Şucan
<span class='line'>  3</span>  *
<span class='line'>  4</span>  * This file is part of PaintWeb.
<span class='line'>  5</span>  *
<span class='line'>  6</span>  * PaintWeb is free software: you can redistribute it and/or modify
<span class='line'>  7</span>  * it under the terms of the GNU General Public License as published by
<span class='line'>  8</span>  * the Free Software Foundation, either version 3 of the License, or
<span class='line'>  9</span>  * (at your option) any later version.
<span class='line'> 10</span>  *
<span class='line'> 11</span>  * PaintWeb is distributed in the hope that it will be useful,
<span class='line'> 12</span>  * but WITHOUT ANY WARRANTY; without even the implied warranty of
<span class='line'> 13</span>  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
<span class='line'> 14</span>  * GNU General Public License for more details.
<span class='line'> 15</span>  *
<span class='line'> 16</span>  * You should have received a copy of the GNU General Public License
<span class='line'> 17</span>  * along with PaintWeb.  If not, see &lt;http://www.gnu.org/licenses/>.
<span class='line'> 18</span>  *
<span class='line'> 19</span>  * $URL: http://code.google.com/p/paintweb $
<span class='line'> 20</span>  * $Date: 2010-06-26 20:35:34 +0300 $
<span class='line'> 21</span>  */</span><span class="WHIT">
<span class='line'> 22</span> 
<span class='line'> 23</span> </span><span class="COMM">/**
<span class='line'> 24</span>  * @author &lt;a lang="ro" href="http://www.robodesign.ro/mihai">Mihai Şucan&lt;/a>
<span class='line'> 25</span>  * @fileOverview Minimal JavaScript library which provides functionality for 
<span class='line'> 26</span>  * cross-browser compatibility support.
<span class='line'> 27</span>  */</span><span class="WHIT">
<span class='line'> 28</span> 
<span class='line'> 29</span> </span><span class="COMM">/**
<span class='line'> 30</span>  * @namespace Holds methods and properties necessary throughout the entire 
<span class='line'> 31</span>  * application.
<span class='line'> 32</span>  */</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">pwlib</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 34</span> 
<span class='line'> 35</span> </span><span class="COMM">/**
<span class='line'> 36</span>  * @namespace Holds pre-packaged files.
<span class='line'> 37</span>  * @type Object
<span class='line'> 38</span>  */</span><span class="WHIT">
<span class='line'> 39</span> </span><span class="NAME">pwlib.fileCache</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 40</span> 
<span class='line'> 41</span> </span><span class="COMM">/**
<span class='line'> 42</span>  * @namespace Holds the implementation of each drawing tool.
<span class='line'> 43</span>  *
<span class='line'> 44</span>  * @type Object
<span class='line'> 45</span>  *
<span class='line'> 46</span>  * @see PaintWeb#toolRegister Register a new drawing tool into a PaintWeb 
<span class='line'> 47</span>  * instance.
<span class='line'> 48</span>  * @see PaintWeb#toolActivate Activate a drawing tool in a PaintWeb instance.
<span class='line'> 49</span>  * @see PaintWeb#toolUnregister Unregister a drawing tool from a PaintWeb 
<span class='line'> 50</span>  * instance.
<span class='line'> 51</span>  *
<span class='line'> 52</span>  * @see PaintWeb.config.toolDefault The default tool being activated when 
<span class='line'> 53</span>  * a PaintWeb instance is initialized.
<span class='line'> 54</span>  * @see PaintWeb.config.tools Holds the list of tools to be loaded automatically 
<span class='line'> 55</span>  * when a PaintWeb instance is initialized.
<span class='line'> 56</span>  */</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="NAME">pwlib.tools</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 58</span> 
<span class='line'> 59</span> </span><span class="COMM">/**
<span class='line'> 60</span>  * @namespace Holds all the PaintWeb extensions.
<span class='line'> 61</span>  *
<span class='line'> 62</span>  * @type Object
<span class='line'> 63</span>  * @see PaintWeb#extensionRegister Register a new extension into a PaintWeb 
<span class='line'> 64</span>  * instance.
<span class='line'> 65</span>  * @see PaintWeb#extensionUnregister Unregister an extension from a PaintWeb 
<span class='line'> 66</span>  * instance.
<span class='line'> 67</span>  * @see PaintWeb.config.extensions Holds the list of extensions to be loaded 
<span class='line'> 68</span>  * automatically when a PaintWeb instance is initialized.
<span class='line'> 69</span>  */</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="NAME">pwlib.extensions</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 71</span> 
<span class='line'> 72</span> </span><span class="COMM">/**
<span class='line'> 73</span>  * This function extends objects.
<span class='line'> 74</span>  *
<span class='line'> 75</span>  * @example
<span class='line'> 76</span>  * &lt;code>var &lt;var>obj1&lt;/var> = {a: 'a1', b: 'b1', d: 'd1'},
<span class='line'> 77</span>  *     &lt;var>obj2&lt;/var> = {a: 'a2', b: 'b2', c: 'c2'};
<span class='line'> 78</span>  * 
<span class='line'> 79</span>  * pwlib.extend(&lt;var>obj1&lt;/var>, &lt;var>obj2&lt;/var>);&lt;/code>
<span class='line'> 80</span>  * 
<span class='line'> 81</span>  * // Now &lt;var>obj1.c == 'c2'&lt;/var>, while &lt;var>obj1.a&lt;/var>, &lt;var>obj1.b&lt;/var>
<span class='line'> 82</span>  * // and &lt;var>obj1.d&lt;/var> remain the same.
<span class='line'> 83</span>  *
<span class='line'> 84</span>  * // If &lt;code>pwlib.extend(true, &lt;var>obj1&lt;/var>, &lt;var>obj2&lt;/var>)&lt;/code> is
<span class='line'> 85</span>  * // called, then &lt;var>obj1.a&lt;/var>, &lt;var>obj1.b&lt;/var>, &lt;var>obj1.c&lt;/var>
<span class='line'> 86</span>  * // become all the same as in &lt;var>obj2&lt;/var>.
<span class='line'> 87</span>  *
<span class='line'> 88</span>  * @example
<span class='line'> 89</span>  * &lt;code>var &lt;var>obj1&lt;/var> = {a: 'a1', b: 'b1', extend: pwlib.extend};
<span class='line'> 90</span>  * &lt;var>obj1&lt;/var>.extend({c: 'c1', d: 'd1'});&lt;/code>
<span class='line'> 91</span>  *
<span class='line'> 92</span>  * // In this case the destination object which is to be extend is
<span class='line'> 93</span>  * // &lt;var>obj1&lt;/var>.
<span class='line'> 94</span>  *
<span class='line'> 95</span>  * @param {Boolean} [overwrite=false] If the first argument is a boolean, then 
<span class='line'> 96</span>  * it will be considered as a boolean flag for overwriting (or not) any existing 
<span class='line'> 97</span>  * methods and properties in the destination object. Thus, any method and 
<span class='line'> 98</span>  * property from the source object will take over those in the destination. The 
<span class='line'> 99</span>  * argument is optional, and if it's omitted, then no method/property will be 
<span class='line'>100</span>  * overwritten.
<span class='line'>101</span>  *
<span class='line'>102</span>  * @param {Object} [destination=this] The second argument is the optional 
<span class='line'>103</span>  * destination object: the object which will be extended. By default, the 
<span class='line'>104</span>  * &lt;var>this&lt;/var> object will be extended.
<span class='line'>105</span>  *
<span class='line'>106</span>  * @param {Object} source The third argument must provide list of methods and 
<span class='line'>107</span>  * properties which will be added to the destination object.
<span class='line'>108</span>  */</span><span class="WHIT">
<span class='line'>109</span> </span><span class="NAME">pwlib.extend</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">src</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sval</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">dval</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>111</span> 
<span class='line'>112</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'boolean'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT">    </span><span class="NAME">force</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT">    </span><span class="NAME">dest</span><span class="WHIT">  </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>115</span> </span><span class="WHIT">    </span><span class="NAME">src</span><span class="WHIT">   </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>116</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>117</span> </span><span class="WHIT">    </span><span class="NAME">force</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT">    </span><span class="NAME">dest</span><span class="WHIT">  </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT">    </span><span class="NAME">src</span><span class="WHIT">   </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>121</span> 
<span class='line'>122</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">src</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT">    </span><span class="NAME">src</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dest</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>124</span> </span><span class="WHIT">    </span><span class="NAME">dest</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>125</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>126</span> 
<span class='line'>127</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">dest</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>128</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>129</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>130</span> 
<span class='line'>131</span> </span><span class="WHIT">  </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">name</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">src</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>132</span> </span><span class="WHIT">    </span><span class="NAME">sval</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">src</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>133</span> </span><span class="WHIT">    </span><span class="NAME">dval</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dest</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>134</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">force</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">dval</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>135</span> </span><span class="WHIT">      </span><span class="NAME">dest</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sval</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>137</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>138</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>139</span> 
<span class='line'>140</span> </span><span class="COMM">/**
<span class='line'>141</span>  * Retrieve a string formatted with the provided variables.
<span class='line'>142</span>  *
<span class='line'>143</span>  * &lt;p>The language string must be available in the global &lt;var>lang&lt;/var> 
<span class='line'>144</span>  * object.
<span class='line'>145</span>  *
<span class='line'>146</span>  * &lt;p>The string can contain any number of variables in the form of 
<span class='line'>147</span>  * &lt;code>{var_name}&lt;/code>.
<span class='line'>148</span>  *
<span class='line'>149</span>  * @example
<span class='line'>150</span>  * lang.table_cells = "The table {name} has {n} cells.";
<span class='line'>151</span>  *
<span class='line'>152</span>  * // later ...
<span class='line'>153</span>  * console.log(pwlib.strf(lang.table_cells, {'name' : 'tbl1', 'n' : 11}));
<span class='line'>154</span>  * // The output is 'The table tbl1 has 11 cells.'
<span class='line'>155</span>  *
<span class='line'>156</span>  * @param {String} str The string you want to output.
<span class='line'>157</span>  *
<span class='line'>158</span>  * @param {Object} [vars] The variables you want to set in the language string.
<span class='line'>159</span>  *
<span class='line'>160</span>  * @returns {String} The string updated with the variables you provided.
<span class='line'>161</span>  */</span><span class="WHIT">
<span class='line'>162</span> </span><span class="NAME">pwlib.strf</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">vars</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>163</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">str</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>164</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">str</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>165</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>166</span> 
<span class='line'>167</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">re</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>168</span> 
<span class='line'>169</span> </span><span class="WHIT">  </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">vars</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>170</span> </span><span class="WHIT">    </span><span class="NAME">re</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">(</span><span class="STRN">'{'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'}'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'g'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>171</span> </span><span class="WHIT">    </span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">str.replace</span><span class="PUNC">(</span><span class="NAME">re</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">vars</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>172</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>173</span> 
<span class='line'>174</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">str</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>175</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>176</span> 
<span class='line'>177</span> </span><span class="COMM">/**
<span class='line'>178</span>  * Parse a JSON string. This method uses the global JSON parser provided by 
<span class='line'>179</span>  * the browser natively. The small difference is that this method allows 
<span class='line'>180</span>  * normal JavaScript comments in the JSON string.
<span class='line'>181</span>  *
<span class='line'>182</span>  * @param {String} str The JSON string to parse.
<span class='line'>183</span>  * @returns The JavaScript object that was parsed.
<span class='line'>184</span>  */</span><span class="WHIT">
<span class='line'>185</span> </span><span class="NAME">pwlib.jsonParse</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>186</span> </span><span class="WHIT">  </span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">str.replace</span><span class="PUNC">(</span><span class="REGX">/\s*\/\*(\s|.)+?\*\//g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>187</span> </span><span class="WHIT">            </span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/^\s*\/\/.*$/gm</span><span class="PUNC">,</span><span class="WHIT">        </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>188</span> 
<span class='line'>189</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">JSON.parse</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>190</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>191</span> 
<span class='line'>192</span> </span><span class="COMM">/**
<span class='line'>193</span>  * Load a file from a given URL using XMLHttpRequest.
<span class='line'>194</span>  *
<span class='line'>195</span>  * @param {String} url The URL you want to load.
<span class='line'>196</span>  *
<span class='line'>197</span>  * @param {Function} handler The &lt;code>onreadystatechange&lt;/code> event handler 
<span class='line'>198</span>  * for the XMLHttpRequest object. Your event handler will always receive the 
<span class='line'>199</span>  * XMLHttpRequest object as the first parameter.
<span class='line'>200</span>  *
<span class='line'>201</span>  * @param {String} [method="GET"] The HTTP method to use for loading the URL.
<span class='line'>202</span>  *
<span class='line'>203</span>  * @param {String} [send=null] The string you want to send in an HTTP POST 
<span class='line'>204</span>  * request.
<span class='line'>205</span>  *
<span class='line'>206</span>  * @param {Object} [headers] An object holding the header names and values you 
<span class='line'>207</span>  * want to set for the request.
<span class='line'>208</span>  *
<span class='line'>209</span>  * @returns {XMLHttpRequest} The XMLHttpRequest object created by this method.
<span class='line'>210</span>  *
<span class='line'>211</span>  * @throws {TypeError} If the &lt;var>url&lt;/var> is not a string.
<span class='line'>212</span>  */</span><span class="WHIT">
<span class='line'>213</span> </span><span class="NAME">pwlib.xhrLoad</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">handler</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">method</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">send</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">headers</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>214</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">url</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>215</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a string!'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>216</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>217</span> 
<span class='line'>218</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">method</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>219</span> </span><span class="WHIT">    </span><span class="NAME">method</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'GET'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>220</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>221</span> 
<span class='line'>222</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">headers</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>223</span> </span><span class="WHIT">    </span><span class="NAME">headers</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>224</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>225</span> 
<span class='line'>226</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">send</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>227</span> </span><span class="WHIT">    </span><span class="NAME">send</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>228</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>229</span> 
<span class='line'>230</span> </span><span class="WHIT">  </span><span class="COMM">/** @ignore */</span><span class="WHIT">
<span class='line'>231</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">xhr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">XMLHttpRequest</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>232</span> </span><span class="WHIT">  </span><span class="COMM">/** @ignore */</span><span class="WHIT">
<span class='line'>233</span> </span><span class="WHIT">  </span><span class="NAME">xhr.onreadystatechange</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">handler</span><span class="PUNC">(</span><span class="NAME">xhr</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>234</span> </span><span class="WHIT">  </span><span class="NAME">xhr.open</span><span class="PUNC">(</span><span class="NAME">method</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">url</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>235</span> 
<span class='line'>236</span> </span><span class="WHIT">  </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">header</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">headers</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>237</span> </span><span class="WHIT">    </span><span class="NAME">xhr.setRequestHeader</span><span class="PUNC">(</span><span class="NAME">header</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">headers</span><span class="PUNC">[</span><span class="NAME">header</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>238</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>239</span> 
<span class='line'>240</span> </span><span class="WHIT">  </span><span class="NAME">xhr.send</span><span class="PUNC">(</span><span class="NAME">send</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>241</span> 
<span class='line'>242</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">xhr</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>243</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>244</span> 
<span class='line'>245</span> </span><span class="COMM">/**
<span class='line'>246</span>  * Check if an URL points to a resource from the same host as the desired one.
<span class='line'>247</span>  *
<span class='line'>248</span>  * &lt;p>Note that data URIs always return true.
<span class='line'>249</span>  *
<span class='line'>250</span>  * @param {String} url The URL you want to check.
<span class='line'>251</span>  * @param {String} host The host you want in the URL. The host name can include 
<span class='line'>252</span>  * the port definition as well.
<span class='line'>253</span>  *
<span class='line'>254</span>  * @returns {Boolean} True if the &lt;var>url&lt;/var> points to a resource from the 
<span class='line'>255</span>  * &lt;var>host&lt;/var> given, or false otherwise.
<span class='line'>256</span>  */</span><span class="WHIT">
<span class='line'>257</span> </span><span class="NAME">pwlib.isSameHost</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">host</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>258</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">url</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">host</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>259</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>260</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>261</span> 
<span class='line'>262</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">pos</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">url.indexOf</span><span class="PUNC">(</span><span class="STRN">':'</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>263</span> </span><span class="WHIT">      </span><span class="NAME">proto</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">url.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pos</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>264</span> 
<span class='line'>265</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">proto</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'data:'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>266</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>267</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>268</span> 
<span class='line'>269</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">proto</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'http:'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">proto</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'https:'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>270</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>271</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>272</span> 
<span class='line'>273</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">urlHost</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">url.replace</span><span class="PUNC">(</span><span class="REGX">/^https?:\/\//i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>274</span> </span><span class="WHIT">  </span><span class="NAME">pos</span><span class="WHIT">  </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">urlHost.indexOf</span><span class="PUNC">(</span><span class="STRN">'/'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>275</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pos</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>276</span> </span><span class="WHIT">    </span><span class="NAME">urlHost</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">urlHost.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pos</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>277</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>278</span> 
<span class='line'>279</span> </span><span class="WHIT">  </span><span class="COMM">// remove default port (80)</span><span class="WHIT">
<span class='line'>280</span> </span><span class="WHIT">  </span><span class="NAME">urlHost</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">urlHost.replace</span><span class="PUNC">(</span><span class="REGX">/:80$/</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>281</span> </span><span class="WHIT">  </span><span class="NAME">host</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">host.replace</span><span class="PUNC">(</span><span class="REGX">/:80$/</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>282</span> 
<span class='line'>283</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">urlHost</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">host</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">urlHost</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">host</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>284</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>285</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>286</span> 
<span class='line'>287</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>288</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>289</span> 
<span class='line'>290</span> </span><span class="COMM">/**
<span class='line'>291</span>  * @class Custom application event.
<span class='line'>292</span>  *
<span class='line'>293</span>  * @param {String} type Event type.
<span class='line'>294</span>  * @param {Boolean} [cancelable=false] Tells if the event can be cancelled or 
<span class='line'>295</span>  * not.
<span class='line'>296</span>  *
<span class='line'>297</span>  * @throws {TypeError} If the &lt;var>type&lt;/var> parameter is not a string.
<span class='line'>298</span>  * @throws {TypeError} If the &lt;var>cancelable&lt;/var> parameter is not a string.
<span class='line'>299</span>  *
<span class='line'>300</span>  * @see pwlib.appEvents for the application events interface which allows adding 
<span class='line'>301</span>  * and removing event listeners.
<span class='line'>302</span>  */</span><span class="WHIT">
<span class='line'>303</span> </span><span class="NAME">pwlib.appEvent</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">cancelable</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>304</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>305</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a string'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>306</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">cancelable</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>307</span> </span><span class="WHIT">    </span><span class="NAME">cancelable</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>308</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">cancelable</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'boolean'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>309</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The second argument must be a boolean'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>310</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>311</span> 
<span class='line'>312</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>313</span>    * Event target object.
<span class='line'>314</span>    * @type Object
<span class='line'>315</span>    */</span><span class="WHIT">
<span class='line'>316</span> </span><span class="WHIT">  </span><span class="NAME">this.target</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>317</span> 
<span class='line'>318</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>319</span>    * Tells if the event can be cancelled or not.
<span class='line'>320</span>    * @type Boolean
<span class='line'>321</span>    */</span><span class="WHIT">
<span class='line'>322</span> </span><span class="WHIT">  </span><span class="NAME">this.cancelable</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">cancelable</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>323</span> 
<span class='line'>324</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>325</span>    * Tells if the event has the default action prevented or not.
<span class='line'>326</span>    * @type Boolean
<span class='line'>327</span>    */</span><span class="WHIT">
<span class='line'>328</span> </span><span class="WHIT">  </span><span class="NAME">this.defaultPrevented</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>329</span> 
<span class='line'>330</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>331</span>    * Event type.
<span class='line'>332</span>    * @type String
<span class='line'>333</span>    */</span><span class="WHIT">
<span class='line'>334</span> </span><span class="WHIT">  </span><span class="NAME">this.type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>335</span> 
<span class='line'>336</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>337</span>    * Prevent the default action of the event.
<span class='line'>338</span>    */</span><span class="WHIT">
<span class='line'>339</span> </span><span class="WHIT">  </span><span class="NAME">this.preventDefault</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>340</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">cancelable</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>341</span> </span><span class="WHIT">      </span><span class="NAME">this.defaultPrevented</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>342</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>343</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>344</span> 
<span class='line'>345</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>346</span>    * Stop the event propagation to other event handlers.
<span class='line'>347</span>    */</span><span class="WHIT">
<span class='line'>348</span> </span><span class="WHIT">  </span><span class="NAME">this.stopPropagation</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>349</span> </span><span class="WHIT">    </span><span class="NAME">this.propagationStopped_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>350</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>351</span> 
<span class='line'>352</span> </span><span class="WHIT">  </span><span class="NAME">this.toString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>353</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">'[pwlib.appEvent.'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.type</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">']'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>354</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>355</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>356</span> 
<span class='line'>357</span> </span><span class="COMM">/**
<span class='line'>358</span>  * @class Application initialization event. This event is not cancelable.
<span class='line'>359</span>  *
<span class='line'>360</span>  * @augments pwlib.appEvent
<span class='line'>361</span>  *
<span class='line'>362</span>  * @param {Number} state The initialization state.
<span class='line'>363</span>  * @param {String} [errorMessage] The error message, if any.
<span class='line'>364</span>  *
<span class='line'>365</span>  * @throws {TypeError} If the &lt;var>state&lt;/var> is not a number.
<span class='line'>366</span>  */</span><span class="WHIT">
<span class='line'>367</span> </span><span class="NAME">pwlib.appEvent.appInit</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">state</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">errorMessage</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>368</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">state</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>369</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a number.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>370</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>371</span> 
<span class='line'>372</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>373</span>    * Application initialization not started.
<span class='line'>374</span>    * @constant
<span class='line'>375</span>    */</span><span class="WHIT">
<span class='line'>376</span> </span><span class="WHIT">  </span><span class="NAME">this.INIT_NOT_STARTED</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>377</span> 
<span class='line'>378</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>379</span>    * Application initialization started.
<span class='line'>380</span>    * @constant
<span class='line'>381</span>    */</span><span class="WHIT">
<span class='line'>382</span> </span><span class="WHIT">  </span><span class="NAME">this.INIT_STARTED</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>383</span> 
<span class='line'>384</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>385</span>    * Application initialization completed successfully.
<span class='line'>386</span>    * @constant
<span class='line'>387</span>    */</span><span class="WHIT">
<span class='line'>388</span> </span><span class="WHIT">  </span><span class="NAME">this.INIT_DONE</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>389</span> 
<span class='line'>390</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>391</span>    * Application initialization failed.
<span class='line'>392</span>    * @constant
<span class='line'>393</span>    */</span><span class="WHIT">
<span class='line'>394</span> </span><span class="WHIT">  </span><span class="NAME">this.INIT_ERROR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>395</span> 
<span class='line'>396</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>397</span>    * Initialization state.
<span class='line'>398</span>    * @type Number
<span class='line'>399</span>    */</span><span class="WHIT">
<span class='line'>400</span> </span><span class="WHIT">  </span><span class="NAME">this.state</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">state</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>401</span> 
<span class='line'>402</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>403</span>    * Initialization error message, if any.
<span class='line'>404</span>    * @type String|null
<span class='line'>405</span>    */</span><span class="WHIT">
<span class='line'>406</span> </span><span class="WHIT">  </span><span class="NAME">this.errorMessage</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">errorMessage</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>407</span> 
<span class='line'>408</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.appEvent.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'appInit'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>409</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>410</span> 
<span class='line'>411</span> </span><span class="COMM">/**
<span class='line'>412</span>  * @class Application destroy event. This event is not cancelable.
<span class='line'>413</span>  *
<span class='line'>414</span>  * @augments pwlib.appEvent
<span class='line'>415</span>  */</span><span class="WHIT">
<span class='line'>416</span> </span><span class="NAME">pwlib.appEvent.appDestroy</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>417</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.appEvent.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'appDestroy'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>418</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>419</span> 
<span class='line'>420</span> </span><span class="COMM">/**
<span class='line'>421</span>  * @class GUI show event. This event is not cancelable.
<span class='line'>422</span>  *
<span class='line'>423</span>  * @augments pwlib.appEvent
<span class='line'>424</span>  */</span><span class="WHIT">
<span class='line'>425</span> </span><span class="NAME">pwlib.appEvent.guiShow</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>426</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.appEvent.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'guiShow'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>427</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>428</span> 
<span class='line'>429</span> </span><span class="COMM">/**
<span class='line'>430</span>  * @class GUI hide event. This event is not cancelable.
<span class='line'>431</span>  *
<span class='line'>432</span>  * @augments pwlib.appEvent
<span class='line'>433</span>  */</span><span class="WHIT">
<span class='line'>434</span> </span><span class="NAME">pwlib.appEvent.guiHide</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>435</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.appEvent.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'guiHide'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>436</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>437</span> 
<span class='line'>438</span> </span><span class="COMM">/**
<span class='line'>439</span>  * @class Tool preactivation event. This event is cancelable.
<span class='line'>440</span>  *
<span class='line'>441</span>  * @augments pwlib.appEvent
<span class='line'>442</span>  *
<span class='line'>443</span>  * @param {String} id The ID of the new tool being activated.
<span class='line'>444</span>  * @param {String|null} prevId The ID of the previous tool.
<span class='line'>445</span>  *
<span class='line'>446</span>  * @throws {TypeError} If the &lt;var>id&lt;/var> is not a string.
<span class='line'>447</span>  * @throws {TypeError} If the &lt;var>prevId&lt;/var> is not a string or null.
<span class='line'>448</span>  */</span><span class="WHIT">
<span class='line'>449</span> </span><span class="NAME">pwlib.appEvent.toolPreactivate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">prevId</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>450</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>451</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a string.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>452</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">prevId</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">prevId</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>453</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The second argument must be a string or null.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>454</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>455</span> 
<span class='line'>456</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>457</span>    * Tool ID.
<span class='line'>458</span>    * @type String
<span class='line'>459</span>    */</span><span class="WHIT">
<span class='line'>460</span> </span><span class="WHIT">  </span><span class="NAME">this.id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>461</span> 
<span class='line'>462</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>463</span>    * Previous tool ID.
<span class='line'>464</span>    * @type String
<span class='line'>465</span>    */</span><span class="WHIT">
<span class='line'>466</span> </span><span class="WHIT">  </span><span class="NAME">this.prevId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">prevId</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>467</span> 
<span class='line'>468</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.appEvent.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'toolPreactivate'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>469</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>470</span> 
<span class='line'>471</span> </span><span class="COMM">/**
<span class='line'>472</span>  * @class Tool activation event. This event is not cancelable.
<span class='line'>473</span>  *
<span class='line'>474</span>  * @augments pwlib.appEvent
<span class='line'>475</span>  *
<span class='line'>476</span>  * @param {String} id The ID the tool which was activated.
<span class='line'>477</span>  * @param {String|null} prevId The ID of the previous tool.
<span class='line'>478</span>  *
<span class='line'>479</span>  * @throws {TypeError} If the &lt;var>id&lt;/var> is not a string.
<span class='line'>480</span>  * @throws {TypeError} If the &lt;var>prevId&lt;/var> is not a string or null.
<span class='line'>481</span>  */</span><span class="WHIT">
<span class='line'>482</span> </span><span class="NAME">pwlib.appEvent.toolActivate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">prevId</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>483</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>484</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a string.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>485</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">prevId</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">prevId</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>486</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The second argument must be a string or null.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>487</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>488</span> 
<span class='line'>489</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>490</span>    * Tool ID.
<span class='line'>491</span>    * @type String
<span class='line'>492</span>    */</span><span class="WHIT">
<span class='line'>493</span> </span><span class="WHIT">  </span><span class="NAME">this.id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>494</span> 
<span class='line'>495</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>496</span>    * Previous tool ID.
<span class='line'>497</span>    * @type String
<span class='line'>498</span>    */</span><span class="WHIT">
<span class='line'>499</span> </span><span class="WHIT">  </span><span class="NAME">this.prevId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">prevId</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>500</span> 
<span class='line'>501</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.appEvent.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'toolActivate'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>502</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>503</span> 
<span class='line'>504</span> </span><span class="COMM">/**
<span class='line'>505</span>  * @class Tool registration event. This event is not cancelable.
<span class='line'>506</span>  *
<span class='line'>507</span>  * @augments pwlib.appEvent
<span class='line'>508</span>  *
<span class='line'>509</span>  * @param {String} id The ID of the tool being registered in an active PaintWeb 
<span class='line'>510</span>  * instance.
<span class='line'>511</span>  *
<span class='line'>512</span>  * @throws {TypeError} If the &lt;var>id&lt;/var> is not a string.
<span class='line'>513</span>  */</span><span class="WHIT">
<span class='line'>514</span> </span><span class="NAME">pwlib.appEvent.toolRegister</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>515</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>516</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a string.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>517</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>518</span> 
<span class='line'>519</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>520</span>    * Tool ID.
<span class='line'>521</span>    * @type String
<span class='line'>522</span>    */</span><span class="WHIT">
<span class='line'>523</span> </span><span class="WHIT">  </span><span class="NAME">this.id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>524</span> 
<span class='line'>525</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.appEvent.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'toolRegister'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>526</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>527</span> 
<span class='line'>528</span> </span><span class="COMM">/**
<span class='line'>529</span>  * @class Tool removal event. This event is not cancelable.
<span class='line'>530</span>  *
<span class='line'>531</span>  * @augments pwlib.appEvent
<span class='line'>532</span>  *
<span class='line'>533</span>  * @param {String} id The ID of the tool being unregistered in an active 
<span class='line'>534</span>  * PaintWeb instance.
<span class='line'>535</span>  *
<span class='line'>536</span>  * @throws {TypeError} If the &lt;var>id&lt;/var> is not a string.
<span class='line'>537</span>  */</span><span class="WHIT">
<span class='line'>538</span> </span><span class="NAME">pwlib.appEvent.toolUnregister</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>539</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>540</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a string.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>541</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>542</span> 
<span class='line'>543</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>544</span>    * Tool ID.
<span class='line'>545</span>    * @type String
<span class='line'>546</span>    */</span><span class="WHIT">
<span class='line'>547</span> </span><span class="WHIT">  </span><span class="NAME">this.id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>548</span> 
<span class='line'>549</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.appEvent.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'toolUnregister'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>550</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>551</span> 
<span class='line'>552</span> </span><span class="COMM">/**
<span class='line'>553</span>  * @class Extension registration event. This event is not cancelable.
<span class='line'>554</span>  *
<span class='line'>555</span>  * @augments pwlib.appEvent
<span class='line'>556</span>  *
<span class='line'>557</span>  * @param {String} id The ID of the extension being registered in an active 
<span class='line'>558</span>  * PaintWeb instance.
<span class='line'>559</span>  *
<span class='line'>560</span>  * @throws {TypeError} If the &lt;var>id&lt;/var> is not a string.
<span class='line'>561</span>  */</span><span class="WHIT">
<span class='line'>562</span> </span><span class="NAME">pwlib.appEvent.extensionRegister</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>563</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>564</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a string.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>565</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>566</span> 
<span class='line'>567</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>568</span>    * Extension ID.
<span class='line'>569</span>    * @type String
<span class='line'>570</span>    */</span><span class="WHIT">
<span class='line'>571</span> </span><span class="WHIT">  </span><span class="NAME">this.id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>572</span> 
<span class='line'>573</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.appEvent.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'extensionRegister'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>574</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>575</span> 
<span class='line'>576</span> </span><span class="COMM">/**
<span class='line'>577</span>  * @class Extension removal event. This event is not cancelable.
<span class='line'>578</span>  *
<span class='line'>579</span>  * @augments pwlib.appEvent
<span class='line'>580</span>  *
<span class='line'>581</span>  * @param {String} id The ID of the extension being unregistered in an active 
<span class='line'>582</span>  * PaintWeb instance.
<span class='line'>583</span>  *
<span class='line'>584</span>  * @throws {TypeError} If the &lt;var>id&lt;/var> is not a string.
<span class='line'>585</span>  */</span><span class="WHIT">
<span class='line'>586</span> </span><span class="NAME">pwlib.appEvent.extensionUnregister</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>587</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>588</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a string.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>589</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>590</span> 
<span class='line'>591</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>592</span>    * Extension ID.
<span class='line'>593</span>    * @type String
<span class='line'>594</span>    */</span><span class="WHIT">
<span class='line'>595</span> </span><span class="WHIT">  </span><span class="NAME">this.id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>596</span> 
<span class='line'>597</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.appEvent.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'extensionUnregister'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>598</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>599</span> 
<span class='line'>600</span> </span><span class="COMM">/**
<span class='line'>601</span>  * @class Command registration event. This event is not cancelable.
<span class='line'>602</span>  *
<span class='line'>603</span>  * @augments pwlib.appEvent
<span class='line'>604</span>  *
<span class='line'>605</span>  * @param {String} id The ID of the command being registered in an active 
<span class='line'>606</span>  * PaintWeb instance.
<span class='line'>607</span>  *
<span class='line'>608</span>  * @throws {TypeError} If the &lt;var>id&lt;/var> is not a string.
<span class='line'>609</span>  */</span><span class="WHIT">
<span class='line'>610</span> </span><span class="NAME">pwlib.appEvent.commandRegister</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>611</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>612</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a string.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>613</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>614</span> 
<span class='line'>615</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>616</span>    * Command ID.
<span class='line'>617</span>    * @type String
<span class='line'>618</span>    */</span><span class="WHIT">
<span class='line'>619</span> </span><span class="WHIT">  </span><span class="NAME">this.id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>620</span> 
<span class='line'>621</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.appEvent.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'commandRegister'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>622</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>623</span> 
<span class='line'>624</span> </span><span class="COMM">/**
<span class='line'>625</span>  * @class Command removal event. This event is not cancelable.
<span class='line'>626</span>  *
<span class='line'>627</span>  * @augments pwlib.appEvent
<span class='line'>628</span>  *
<span class='line'>629</span>  * @param {String} id The ID of the command being unregistered in an active 
<span class='line'>630</span>  * PaintWeb instance.
<span class='line'>631</span>  *
<span class='line'>632</span>  * @throws {TypeError} If the &lt;var>id&lt;/var> is not a string.
<span class='line'>633</span>  */</span><span class="WHIT">
<span class='line'>634</span> </span><span class="NAME">pwlib.appEvent.commandUnregister</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>635</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>636</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a string.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>637</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>638</span> 
<span class='line'>639</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>640</span>    * Command ID.
<span class='line'>641</span>    * @type String
<span class='line'>642</span>    */</span><span class="WHIT">
<span class='line'>643</span> </span><span class="WHIT">  </span><span class="NAME">this.id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>644</span> 
<span class='line'>645</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.appEvent.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'commandUnregister'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>646</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>647</span> 
<span class='line'>648</span> </span><span class="COMM">/**
<span class='line'>649</span>  * @class The image save event. This event is cancelable.
<span class='line'>650</span>  *
<span class='line'>651</span>  * @augments pwlib.appEvent
<span class='line'>652</span>  *
<span class='line'>653</span>  * @param {String} dataURL The data URL generated by the browser holding the 
<span class='line'>654</span>  * pixels of the image being saved, in PNG format.
<span class='line'>655</span>  * @param {Number} width The image width.
<span class='line'>656</span>  * @param {Number} height The image height.
<span class='line'>657</span>  */</span><span class="WHIT">
<span class='line'>658</span> </span><span class="NAME">pwlib.appEvent.imageSave</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">dataURL</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">width</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">height</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>659</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>660</span>    * The image saved by the browser, using the base64 encoding.
<span class='line'>661</span>    * @type String
<span class='line'>662</span>    */</span><span class="WHIT">
<span class='line'>663</span> </span><span class="WHIT">  </span><span class="NAME">this.dataURL</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataURL</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>664</span> 
<span class='line'>665</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>666</span>    * Image width.
<span class='line'>667</span>    * @type Number
<span class='line'>668</span>    */</span><span class="WHIT">
<span class='line'>669</span> </span><span class="WHIT">  </span><span class="NAME">this.width</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">width</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>670</span> 
<span class='line'>671</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>672</span>    * Image height.
<span class='line'>673</span>    * @type Number
<span class='line'>674</span>    */</span><span class="WHIT">
<span class='line'>675</span> </span><span class="WHIT">  </span><span class="NAME">this.height</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">height</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>676</span> 
<span class='line'>677</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.appEvent.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'imageSave'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>678</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>679</span> </span><span class="COMM">/**
<span class='line'>680</span>  * @class The image save result event. This event is not cancelable.
<span class='line'>681</span>  *
<span class='line'>682</span>  * @augments pwlib.appEvent
<span class='line'>683</span>  *
<span class='line'>684</span>  * @param {Boolean} successful Tells if the image save was successful or not.
<span class='line'>685</span>  * @param {String} [url] The image address.
<span class='line'>686</span>  * @param {String} [urlNew] The new image address. Provide this parameter, if, 
<span class='line'>687</span>  * for example, you allow saving images from a remote server to a local server.  
<span class='line'>688</span>  * In such cases the image address changes.
<span class='line'>689</span>  */</span><span class="WHIT">
<span class='line'>690</span> </span><span class="NAME">pwlib.appEvent.imageSaveResult</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">successful</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">urlNew</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>691</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>692</span>    * Tells if the image save was successful or not.
<span class='line'>693</span>    * @type String
<span class='line'>694</span>    */</span><span class="WHIT">
<span class='line'>695</span> </span><span class="WHIT">  </span><span class="NAME">this.successful</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">successful</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>696</span> 
<span class='line'>697</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>698</span>    * The image address.
<span class='line'>699</span>    * @type String|null
<span class='line'>700</span>    */</span><span class="WHIT">
<span class='line'>701</span> </span><span class="WHIT">  </span><span class="NAME">this.url</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">url</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>702</span> 
<span class='line'>703</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>704</span>    * The new image address.
<span class='line'>705</span>    * @type String|null
<span class='line'>706</span>    */</span><span class="WHIT">
<span class='line'>707</span> </span><span class="WHIT">  </span><span class="NAME">this.urlNew</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">urlNew</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>708</span> 
<span class='line'>709</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.appEvent.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'imageSaveResult'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>710</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>711</span> 
<span class='line'>712</span> </span><span class="COMM">/**
<span class='line'>713</span>  * @class History navigation event. This event is not cancelable.
<span class='line'>714</span>  *
<span class='line'>715</span>  * @augments pwlib.appEvent
<span class='line'>716</span>  *
<span class='line'>717</span>  * @param {Number} currentPos The new history position.
<span class='line'>718</span>  * @param {Number} previousPos The previous history position.
<span class='line'>719</span>  * @param {Number} states The number of history states available.
<span class='line'>720</span>  *
<span class='line'>721</span>  * @throws {TypeError} If any of the arguments are not numbers.
<span class='line'>722</span>  */</span><span class="WHIT">
<span class='line'>723</span> </span><span class="NAME">pwlib.appEvent.historyUpdate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">currentPos</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">previousPos</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">states</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>724</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">currentPos</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">previousPos</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> 
<span class='line'>725</span>       </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">states</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>726</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'All arguments must be numbers.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>727</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>728</span> 
<span class='line'>729</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>730</span>    * Current history position.
<span class='line'>731</span>    * @type Number
<span class='line'>732</span>    */</span><span class="WHIT">
<span class='line'>733</span> </span><span class="WHIT">  </span><span class="NAME">this.currentPos</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">currentPos</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>734</span> 
<span class='line'>735</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>736</span>    * Previous history position.
<span class='line'>737</span>    * @type Number
<span class='line'>738</span>    */</span><span class="WHIT">
<span class='line'>739</span> </span><span class="WHIT">  </span><span class="NAME">this.previousPos</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">previousPos</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>740</span> 
<span class='line'>741</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>742</span>    * History states count.
<span class='line'>743</span>    * @type Number
<span class='line'>744</span>    */</span><span class="WHIT">
<span class='line'>745</span> </span><span class="WHIT">  </span><span class="NAME">this.states</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">states</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>746</span> 
<span class='line'>747</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.appEvent.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'historyUpdate'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>748</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>749</span> 
<span class='line'>750</span> </span><span class="COMM">/**
<span class='line'>751</span>  * @class Image size change event. This event is not cancelable.
<span class='line'>752</span>  *
<span class='line'>753</span>  * @augments pwlib.appEvent
<span class='line'>754</span>  *
<span class='line'>755</span>  * @param {Number} width The new image width.
<span class='line'>756</span>  * @param {Number} height The new image height.
<span class='line'>757</span>  *
<span class='line'>758</span>  * @throws {TypeError} If any of the arguments are not numbers.
<span class='line'>759</span>  */</span><span class="WHIT">
<span class='line'>760</span> </span><span class="NAME">pwlib.appEvent.imageSizeChange</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">width</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">height</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>761</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">width</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">height</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>762</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'Both arguments must be numbers.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>763</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>764</span> 
<span class='line'>765</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>766</span>    * New image width.
<span class='line'>767</span>    * @type Number
<span class='line'>768</span>    */</span><span class="WHIT">
<span class='line'>769</span> </span><span class="WHIT">  </span><span class="NAME">this.width</span><span class="WHIT">  </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">width</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>770</span> 
<span class='line'>771</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>772</span>    * New image height.
<span class='line'>773</span>    * @type Number
<span class='line'>774</span>    */</span><span class="WHIT">
<span class='line'>775</span> </span><span class="WHIT">  </span><span class="NAME">this.height</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">height</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>776</span> 
<span class='line'>777</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.appEvent.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'imageSizeChange'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>778</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>779</span> 
<span class='line'>780</span> </span><span class="COMM">/**
<span class='line'>781</span>  * @class Canvas size change event. This event is not cancelable.
<span class='line'>782</span>  *
<span class='line'>783</span>  * &lt;p>Note that the Canvas size is not the same as the image size. Canvas size 
<span class='line'>784</span>  * refers to the scaling of the Canvas elements being applied (due to image 
<span class='line'>785</span>  * zooming or due to browser zoom / DPI).
<span class='line'>786</span>  *
<span class='line'>787</span>  * @augments pwlib.appEvent
<span class='line'>788</span>  *
<span class='line'>789</span>  * @param {Number} width The new Canvas style width.
<span class='line'>790</span>  * @param {Number} height The new Canvas style height.
<span class='line'>791</span>  * @param {Number} scale The new Canvas scaling factor.
<span class='line'>792</span>  *
<span class='line'>793</span>  * @throws {TypeError} If any of the arguments are not numbers.
<span class='line'>794</span>  */</span><span class="WHIT">
<span class='line'>795</span> </span><span class="NAME">pwlib.appEvent.canvasSizeChange</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">width</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">height</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>796</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">width</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">height</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="WHIT"> 
<span class='line'>797</span>       </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>798</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'All the arguments must be numbers.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>799</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>800</span> 
<span class='line'>801</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>802</span>    * New Canvas style width.
<span class='line'>803</span>    * @type Number
<span class='line'>804</span>    */</span><span class="WHIT">
<span class='line'>805</span> </span><span class="WHIT">  </span><span class="NAME">this.width</span><span class="WHIT">  </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">width</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>806</span> 
<span class='line'>807</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>808</span>    * New Canvas style height.
<span class='line'>809</span>    * @type Number
<span class='line'>810</span>    */</span><span class="WHIT">
<span class='line'>811</span> </span><span class="WHIT">  </span><span class="NAME">this.height</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">height</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>812</span> 
<span class='line'>813</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>814</span>    * The new Canvas scaling factor.
<span class='line'>815</span>    * @type Number
<span class='line'>816</span>    */</span><span class="WHIT">
<span class='line'>817</span> </span><span class="WHIT">  </span><span class="NAME">this.scale</span><span class="WHIT">  </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>818</span> 
<span class='line'>819</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.appEvent.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'canvasSizeChange'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>820</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>821</span> 
<span class='line'>822</span> </span><span class="COMM">/**
<span class='line'>823</span>  * @class Image viewport size change event. This event is not cancelable.
<span class='line'>824</span>  *
<span class='line'>825</span>  * @augments pwlib.appEvent
<span class='line'>826</span>  *
<span class='line'>827</span>  * @param {String} width The new viewport width. This must be a CSS length 
<span class='line'>828</span>  * value, like "100px", "100%" or "100em".
<span class='line'>829</span>  *
<span class='line'>830</span>  * @param {String} height The new viewport height. This must be a CSS length 
<span class='line'>831</span>  * value, like "100px", "100%" or "100em".
<span class='line'>832</span>  */</span><span class="WHIT">
<span class='line'>833</span> </span><span class="NAME">pwlib.appEvent.viewportSizeChange</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">width</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">height</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>834</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>835</span>    * New viewport width.
<span class='line'>836</span>    * @type String
<span class='line'>837</span>    */</span><span class="WHIT">
<span class='line'>838</span> </span><span class="WHIT">  </span><span class="NAME">this.width</span><span class="WHIT">  </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">width</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>839</span> 
<span class='line'>840</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>841</span>    * New viewport height.
<span class='line'>842</span>    * @type String
<span class='line'>843</span>    */</span><span class="WHIT">
<span class='line'>844</span> </span><span class="WHIT">  </span><span class="NAME">this.height</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">height</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>845</span> 
<span class='line'>846</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.appEvent.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'viewportSizeChange'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>847</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>848</span> 
<span class='line'>849</span> 
<span class='line'>850</span> </span><span class="COMM">/**
<span class='line'>851</span>  * @class Image zoom event. This event is cancelable.
<span class='line'>852</span>  *
<span class='line'>853</span>  * @augments pwlib.appEvent
<span class='line'>854</span>  *
<span class='line'>855</span>  * @param {Number} zoom The new image zoom level.
<span class='line'>856</span>  *
<span class='line'>857</span>  * @throws {TypeError} If the &lt;var>zoom&lt;/var> argument is not a number.
<span class='line'>858</span>  */</span><span class="WHIT">
<span class='line'>859</span> </span><span class="NAME">pwlib.appEvent.imageZoom</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">zoom</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>860</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">zoom</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>861</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a number.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>862</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>863</span> 
<span class='line'>864</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>865</span>    * The new image zoom level.
<span class='line'>866</span>    * @type Number
<span class='line'>867</span>    */</span><span class="WHIT">
<span class='line'>868</span> </span><span class="WHIT">  </span><span class="NAME">this.zoom</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">zoom</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>869</span> 
<span class='line'>870</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.appEvent.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'imageZoom'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>871</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>872</span> 
<span class='line'>873</span> </span><span class="COMM">/**
<span class='line'>874</span>  * @class Image crop event. This event is cancelable.
<span class='line'>875</span>  *
<span class='line'>876</span>  * @augments pwlib.appEvent
<span class='line'>877</span>  *
<span class='line'>878</span>  * @param {Number} x The crop start position on the x-axis.
<span class='line'>879</span>  * @param {Number} y The crop start position on the y-axis.
<span class='line'>880</span>  * @param {Number} width The cropped image width.
<span class='line'>881</span>  * @param {Number} height The cropped image height.
<span class='line'>882</span>  *
<span class='line'>883</span>  * @throws {TypeError} If any of the arguments are not numbers.
<span class='line'>884</span>  */</span><span class="WHIT">
<span class='line'>885</span> </span><span class="NAME">pwlib.appEvent.imageCrop</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">width</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">height</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>886</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">y</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">width</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> 
<span class='line'>887</span>       </span><span class="STRN">'number'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">height</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>888</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'All arguments must be numbers.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>889</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>890</span> 
<span class='line'>891</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>892</span>    * The crop start position the x-axis.
<span class='line'>893</span>    * @type Number
<span class='line'>894</span>    */</span><span class="WHIT">
<span class='line'>895</span> </span><span class="WHIT">  </span><span class="NAME">this.x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>896</span> 
<span class='line'>897</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>898</span>    * The crop start position the y-axis.
<span class='line'>899</span>    * @type Number
<span class='line'>900</span>    */</span><span class="WHIT">
<span class='line'>901</span> </span><span class="WHIT">  </span><span class="NAME">this.y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>902</span> 
<span class='line'>903</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>904</span>    * The cropped image width.
<span class='line'>905</span>    * @type Number
<span class='line'>906</span>    */</span><span class="WHIT">
<span class='line'>907</span> </span><span class="WHIT">  </span><span class="NAME">this.width</span><span class="WHIT">  </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">width</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>908</span> 
<span class='line'>909</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>910</span>    * The cropped image height.
<span class='line'>911</span>    * @type Number
<span class='line'>912</span>    */</span><span class="WHIT">
<span class='line'>913</span> </span><span class="WHIT">  </span><span class="NAME">this.height</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">height</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>914</span> 
<span class='line'>915</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.appEvent.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'imageCrop'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>916</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>917</span> 
<span class='line'>918</span> </span><span class="COMM">/**
<span class='line'>919</span>  * @class Configuration change event. This event is not cancelable.
<span class='line'>920</span>  *
<span class='line'>921</span>  * @augments pwlib.appEvent
<span class='line'>922</span>  *
<span class='line'>923</span>  * @param {String|Number|Boolean} value The new value.
<span class='line'>924</span>  * @param {String|Number|Boolean} previousValue The previous value.
<span class='line'>925</span>  * @param {String} config The configuration property that just changed.
<span class='line'>926</span>  * @param {String} group The configuration group where the property is found.
<span class='line'>927</span>  * @param {Object} groupRef The configuration group object reference.
<span class='line'>928</span>  *
<span class='line'>929</span>  * @throws {TypeError} If the &lt;var>prop&lt;/var> argument is not a string.
<span class='line'>930</span>  * @throws {TypeError} If the &lt;var>group&lt;/var> argument is not a string.
<span class='line'>931</span>  * @throws {TypeError} If the &lt;var>groupRef&lt;/var> argument is not an object.
<span class='line'>932</span>  */</span><span class="WHIT">
<span class='line'>933</span> </span><span class="NAME">pwlib.appEvent.configChange</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">previousValue</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">config</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">group</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>934</span>     </span><span class="NAME">groupRef</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>935</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">config</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>936</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The third argument must be a string.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>937</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">group</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>938</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The fourth argument must be a string.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>939</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">groupRef</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>940</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The fifth argument must be an object.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>941</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>942</span> 
<span class='line'>943</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>944</span>    * The new value.
<span class='line'>945</span>    */</span><span class="WHIT">
<span class='line'>946</span> </span><span class="WHIT">  </span><span class="NAME">this.value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>947</span> 
<span class='line'>948</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>949</span>    * The previous value.
<span class='line'>950</span>    */</span><span class="WHIT">
<span class='line'>951</span> </span><span class="WHIT">  </span><span class="NAME">this.previousValue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">previousValue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>952</span> 
<span class='line'>953</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>954</span>    * Configuration property name.
<span class='line'>955</span>    * @type String
<span class='line'>956</span>    */</span><span class="WHIT">
<span class='line'>957</span> </span><span class="WHIT">  </span><span class="NAME">this.config</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">config</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>958</span> 
<span class='line'>959</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>960</span>    * Configuration group name.
<span class='line'>961</span>    * @type String
<span class='line'>962</span>    */</span><span class="WHIT">
<span class='line'>963</span> </span><span class="WHIT">  </span><span class="NAME">this.group</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">group</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>964</span> 
<span class='line'>965</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>966</span>    * Reference to the object holding the configuration property.
<span class='line'>967</span>    * @type Object
<span class='line'>968</span>    */</span><span class="WHIT">
<span class='line'>969</span> </span><span class="WHIT">  </span><span class="NAME">this.groupRef</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">groupRef</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>970</span> 
<span class='line'>971</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.appEvent.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'configChange'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>972</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>973</span> 
<span class='line'>974</span> </span><span class="COMM">/**
<span class='line'>975</span>  * @class Canvas shadows allowed change event. This event is not cancelable.
<span class='line'>976</span>  *
<span class='line'>977</span>  * @augments pwlib.appEvent
<span class='line'>978</span>  *
<span class='line'>979</span>  * @param {Boolean} allowed Tells the new allowance value.
<span class='line'>980</span>  *
<span class='line'>981</span>  * @throws {TypeError} If the argument is not a boolean value.
<span class='line'>982</span>  */</span><span class="WHIT">
<span class='line'>983</span> </span><span class="NAME">pwlib.appEvent.shadowAllow</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">allowed</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>984</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">allowed</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'boolean'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>985</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a boolean.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>986</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>987</span> 
<span class='line'>988</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>989</span>    * Tells if the Canvas shadows are allowed or not.
<span class='line'>990</span>    * @type Boolean
<span class='line'>991</span>    */</span><span class="WHIT">
<span class='line'>992</span> </span><span class="WHIT">  </span><span class="NAME">this.allowed</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">allowed</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>993</span> 
<span class='line'>994</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.appEvent.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'shadowAllow'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>995</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>996</span> 
<span class='line'>997</span> </span><span class="COMM">/**
<span class='line'>998</span>  * @class Clipboard update event. This event is not cancelable.
<span class='line'>999</span>  *
<span class='line'>1000</span>  * @augments pwlib.appEvent
<span class='line'>1001</span>  *
<span class='line'>1002</span>  * @param {ImageData} data Holds the clipboard ImageData.
<span class='line'>1003</span>  */</span><span class="WHIT">
<span class='line'>1004</span> </span><span class="NAME">pwlib.appEvent.clipboardUpdate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1005</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>1006</span>    * The clipboard image data.
<span class='line'>1007</span>    * @type ImageData
<span class='line'>1008</span>    */</span><span class="WHIT">
<span class='line'>1009</span> </span><span class="WHIT">  </span><span class="NAME">this.data</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1010</span> 
<span class='line'>1011</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.appEvent.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'clipboardUpdate'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1012</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1013</span> 
<span class='line'>1014</span> </span><span class="COMM">/**
<span class='line'>1015</span>  * @class An interface for adding, removing and dispatching of custom 
<span class='line'>1016</span>  * application events.
<span class='line'>1017</span>  *
<span class='line'>1018</span>  * @param {Object} target_ The target for all the events.
<span class='line'>1019</span>  *
<span class='line'>1020</span>  * @see pwlib.appEvent to create application event objects.
<span class='line'>1021</span>  */</span><span class="WHIT">
<span class='line'>1022</span> </span><span class="NAME">pwlib.appEvents</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">target_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1023</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>1024</span>    * Holds the list of event types and event handlers.
<span class='line'>1025</span>    *
<span class='line'>1026</span>    * @private
<span class='line'>1027</span>    * @type Object
<span class='line'>1028</span>    */</span><span class="WHIT">
<span class='line'>1029</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">events_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1030</span> 
<span class='line'>1031</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">eventID_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1032</span> 
<span class='line'>1033</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>1034</span>    * Add an event listener.
<span class='line'>1035</span>    *
<span class='line'>1036</span>    * @param {String} type The event you want to listen for.
<span class='line'>1037</span>    * @param {Function} handler The event handler.
<span class='line'>1038</span>    *
<span class='line'>1039</span>    * @returns {Number} The event ID.
<span class='line'>1040</span>    *
<span class='line'>1041</span>    * @throws {TypeError} If the &lt;var>type&lt;/var> argument is not a string.
<span class='line'>1042</span>    * @throws {TypeError} If the &lt;var>handler&lt;/var> argument is not a function.
<span class='line'>1043</span>    *
<span class='line'>1044</span>    * @see pwlib.appEvents#remove to remove events.
<span class='line'>1045</span>    * @see pwlib.appEvents#dispatch to dispatch an event.
<span class='line'>1046</span>    */</span><span class="WHIT">
<span class='line'>1047</span> </span><span class="WHIT">  </span><span class="NAME">this.add</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">handler</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1048</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1049</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a string.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1050</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">handler</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1051</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The second argument must be a function.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1052</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1053</span> 
<span class='line'>1054</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">eventID_</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1055</span> 
<span class='line'>1056</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">events_</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1057</span> </span><span class="WHIT">      </span><span class="NAME">events_</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1058</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1059</span> 
<span class='line'>1060</span> </span><span class="WHIT">    </span><span class="NAME">events_</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">handler</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1061</span> 
<span class='line'>1062</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1063</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1064</span> 
<span class='line'>1065</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>1066</span>    * Remove an event listener.
<span class='line'>1067</span>    *
<span class='line'>1068</span>    * @param {String} type The event type.
<span class='line'>1069</span>    * @param {Number} id The event ID.
<span class='line'>1070</span>    *
<span class='line'>1071</span>    * @throws {TypeError} If the &lt;var>type&lt;/var> argument is not a string.
<span class='line'>1072</span>    *
<span class='line'>1073</span>    * @see pwlib.appEvents#add to add events.
<span class='line'>1074</span>    * @see pwlib.appEvents#dispatch to dispatch an event.
<span class='line'>1075</span>    */</span><span class="WHIT">
<span class='line'>1076</span> </span><span class="WHIT">  </span><span class="NAME">this.remove</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1077</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1078</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a string.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1079</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1080</span> 
<span class='line'>1081</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">events_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">id</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">events_</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1082</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1083</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1084</span> 
<span class='line'>1085</span> </span><span class="WHIT">    </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">events_</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1086</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1087</span> 
<span class='line'>1088</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>1089</span>    * Dispatch an event.
<span class='line'>1090</span>    *
<span class='line'>1091</span>    * @param {String} type The event type.
<span class='line'>1092</span>    * @param {pwlib.appEvent} ev The event object.
<span class='line'>1093</span>    *
<span class='line'>1094</span>    * @returns {Boolean} True if the &lt;code>event.preventDefault()&lt;/code> has been 
<span class='line'>1095</span>    * invoked by one of the event handlers, or false if not.
<span class='line'>1096</span>    *
<span class='line'>1097</span>    * @throws {TypeError} If the &lt;var>type&lt;/var> parameter is not a string.
<span class='line'>1098</span>    * @throws {TypeError} If the &lt;var>ev&lt;/var> parameter is not an object.
<span class='line'>1099</span>    *
<span class='line'>1100</span>    * @see pwlib.appEvents#add to add events.
<span class='line'>1101</span>    * @see pwlib.appEvents#remove to remove events.
<span class='line'>1102</span>    * @see pwlib.appEvent the generic event object.
<span class='line'>1103</span>    */</span><span class="WHIT">
<span class='line'>1104</span> </span><span class="WHIT">  </span><span class="NAME">this.dispatch</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1105</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">ev</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1106</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The second argument must be an object.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1107</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">ev.type</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1108</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The second argument must be an application event '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>1109</span> </span><span class="WHIT">        </span><span class="STRN">'object.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1110</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1111</span> 
<span class='line'>1112</span> </span><span class="WHIT">    </span><span class="COMM">// No event handlers.</span><span class="WHIT">
<span class='line'>1113</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">ev.type</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">events_</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1114</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1115</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1116</span> 
<span class='line'>1117</span> </span><span class="WHIT">    </span><span class="NAME">ev.target</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">target_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1118</span> 
<span class='line'>1119</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">handlers</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">events_</span><span class="PUNC">[</span><span class="NAME">ev.type</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1120</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">handlers</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1121</span> </span><span class="WHIT">      </span><span class="NAME">handlers</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">call</span><span class="PUNC">(</span><span class="NAME">target_</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ev</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1122</span> 
<span class='line'>1123</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev.propagationStopped_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1124</span> </span><span class="WHIT">        </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1125</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1126</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1127</span> 
<span class='line'>1128</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">ev.defaultPrevented</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1129</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1130</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1131</span> 
<span class='line'>1132</span> 
<span class='line'>1133</span> </span><span class="COMM">/**
<span class='line'>1134</span>  * @namespace Holds browser information.
<span class='line'>1135</span>  */</span><span class="WHIT">
<span class='line'>1136</span> </span><span class="NAME">pwlib.browser</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1137</span> 
<span class='line'>1138</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1139</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ua</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1140</span> 
<span class='line'>1141</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">window.navigator</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">window.navigator.userAgent</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1142</span> </span><span class="WHIT">  </span><span class="NAME">ua</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.navigator.userAgent.toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1143</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1144</span> 
<span class='line'>1145</span> </span><span class="COMM">/**
<span class='line'>1146</span>  * @type Boolean
<span class='line'>1147</span>  */</span><span class="WHIT">
<span class='line'>1148</span> </span><span class="NAME">pwlib.browser.opera</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.opera</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="REGX">/\bopera\b/</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">ua</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1149</span> 
<span class='line'>1150</span> </span><span class="COMM">/**
<span class='line'>1151</span>  * Webkit is the render engine used primarily by Safari. It's also used by 
<span class='line'>1152</span>  * Google Chrome and GNOME Epiphany.
<span class='line'>1153</span>  *
<span class='line'>1154</span>  * @type Boolean
<span class='line'>1155</span>  */</span><span class="WHIT">
<span class='line'>1156</span> </span><span class="NAME">pwlib.browser.webkit</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">pwlib.browser.opera</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>1157</span> </span><span class="WHIT">                       </span><span class="REGX">/\b(applewebkit|webkit)\b/</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">ua</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1158</span> 
<span class='line'>1159</span> </span><span class="COMM">/**
<span class='line'>1160</span>  * Firefox uses the Gecko render engine.
<span class='line'>1161</span>  *
<span class='line'>1162</span>  * @type Boolean
<span class='line'>1163</span>  */</span><span class="WHIT">
<span class='line'>1164</span> </span><span class="COMM">// In some variations of the User Agent strings provided by Opera, Firefox is </span><span class="WHIT">
<span class='line'>1165</span> </span><span class="COMM">// mentioned.</span><span class="WHIT">
<span class='line'>1166</span> </span><span class="NAME">pwlib.browser.firefox</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/\bfirefox\b/</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">ua</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">pwlib.browser.opera</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1167</span> 
<span class='line'>1168</span> </span><span class="COMM">/**
<span class='line'>1169</span>  * Gecko is the render engine used by Firefox and related products.
<span class='line'>1170</span>  *
<span class='line'>1171</span>  * @type Boolean
<span class='line'>1172</span>  */</span><span class="WHIT">
<span class='line'>1173</span> </span><span class="COMM">// Typically, the user agent string of WebKit also mentions Gecko. Additionally, </span><span class="WHIT">
<span class='line'>1174</span> </span><span class="COMM">// Opera mentions Gecko for tricking some sites.</span><span class="WHIT">
<span class='line'>1175</span> </span><span class="NAME">pwlib.browser.gecko</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/\bgecko\b/</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">ua</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">pwlib.browser.opera</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>1176</span> </span><span class="WHIT">                      </span><span class="PUNC">!</span><span class="NAME">pwlib.browser.webkit</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1177</span> 
<span class='line'>1178</span> </span><span class="COMM">/**
<span class='line'>1179</span>  * Microsoft Internet Explorer. The future of computing.
<span class='line'>1180</span>  *
<span class='line'>1181</span>  * @type Boolean
<span class='line'>1182</span>  */</span><span class="WHIT">
<span class='line'>1183</span> </span><span class="COMM">// Again, Opera allows users to easily fake the UA.</span><span class="WHIT">
<span class='line'>1184</span> </span><span class="NAME">pwlib.browser.msie</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/\bmsie\b/</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">ua</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">pwlib.browser.opera</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1185</span> 
<span class='line'>1186</span> </span><span class="COMM">/**
<span class='line'>1187</span>  * Presto is the render engine used by Opera.
<span class='line'>1188</span>  *
<span class='line'>1189</span>  * @type Boolean
<span class='line'>1190</span>  */</span><span class="WHIT">
<span class='line'>1191</span> </span><span class="COMM">// Older versions of Opera did not mention Presto in the UA string.</span><span class="WHIT">
<span class='line'>1192</span> </span><span class="NAME">pwlib.browser.presto</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/\bpresto\b/</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">ua</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">pwlib.browser.opera</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1193</span> 
<span class='line'>1194</span> 
<span class='line'>1195</span> </span><span class="COMM">/**
<span class='line'>1196</span>  * Browser operating system
<span class='line'>1197</span>  *
<span class='line'>1198</span>  * @type String
<span class='line'>1199</span>  */</span><span class="WHIT">
<span class='line'>1200</span> </span><span class="NAME">pwlib.browser.os</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ua.match</span><span class="PUNC">(</span><span class="REGX">/\b(windows|linux)\b/</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1201</span> 
<span class='line'>1202</span> </span><span class="COMM">/**
<span class='line'>1203</span>  * Tells if the browser is running on an OLPC XO. Typically, only the default 
<span class='line'>1204</span>  * Gecko-based browser includes the OLPC XO tokens in the user agent string.
<span class='line'>1205</span>  *
<span class='line'>1206</span>  * @type Boolean
<span class='line'>1207</span>  */</span><span class="WHIT">
<span class='line'>1208</span> </span><span class="NAME">pwlib.browser.olpcxo</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/\bolpc\b/</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">ua</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="REGX">/\bxo\b/</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">ua</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1209</span> 
<span class='line'>1210</span> </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">ua</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1211</span> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1212</span> 
<span class='line'>1213</span> 
<span class='line'>1214</span> </span><span class="COMM">/**
<span class='line'>1215</span>  * @namespace Holds methods and properties necessary for DOM manipulation.
<span class='line'>1216</span>  */</span><span class="WHIT">
<span class='line'>1217</span> </span><span class="NAME">pwlib.dom</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1218</span> 
<span class='line'>1219</span> </span><span class="COMM">/**
<span class='line'>1220</span>  * @namespace Holds the list of virtual key identifiers and a few characters, 
<span class='line'>1221</span>  * each being associated to a key code commonly used by Web browsers.
<span class='line'>1222</span>  *
<span class='line'>1223</span>  * @private
<span class='line'>1224</span>  */</span><span class="WHIT">
<span class='line'>1225</span> </span><span class="NAME">pwlib.dom.keyNames</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1226</span> </span><span class="WHIT">  </span><span class="NAME">Help</span><span class="PUNC">:</span><span class="WHIT">          </span><span class="NUMB">6</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1227</span> </span><span class="WHIT">  </span><span class="NAME">Backspace</span><span class="PUNC">:</span><span class="WHIT">     </span><span class="NUMB">8</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1228</span> </span><span class="WHIT">  </span><span class="NAME">Tab</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">9</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1229</span> </span><span class="WHIT">  </span><span class="NAME">Clear</span><span class="PUNC">:</span><span class="WHIT">         </span><span class="NUMB">12</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1230</span> </span><span class="WHIT">  </span><span class="NAME">Enter</span><span class="PUNC">:</span><span class="WHIT">         </span><span class="NUMB">13</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1231</span> </span><span class="WHIT">  </span><span class="NAME">Shift</span><span class="PUNC">:</span><span class="WHIT">         </span><span class="NUMB">16</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1232</span> </span><span class="WHIT">  </span><span class="NAME">Control</span><span class="PUNC">:</span><span class="WHIT">       </span><span class="NUMB">17</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1233</span> </span><span class="WHIT">  </span><span class="NAME">Alt</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">18</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1234</span> </span><span class="WHIT">  </span><span class="NAME">Pause</span><span class="PUNC">:</span><span class="WHIT">         </span><span class="NUMB">19</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1235</span> </span><span class="WHIT">  </span><span class="NAME">CapsLock</span><span class="PUNC">:</span><span class="WHIT">      </span><span class="NUMB">20</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1236</span> </span><span class="WHIT">  </span><span class="NAME">Cancel</span><span class="PUNC">:</span><span class="WHIT">        </span><span class="NUMB">24</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1237</span> </span><span class="WHIT">  </span><span class="STRN">'Escape'</span><span class="PUNC">:</span><span class="WHIT">      </span><span class="NUMB">27</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1238</span> </span><span class="WHIT">  </span><span class="NAME">Space</span><span class="PUNC">:</span><span class="WHIT">         </span><span class="NUMB">32</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1239</span> </span><span class="WHIT">  </span><span class="NAME">PageUp</span><span class="PUNC">:</span><span class="WHIT">        </span><span class="NUMB">33</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1240</span> </span><span class="WHIT">  </span><span class="NAME">PageDown</span><span class="PUNC">:</span><span class="WHIT">      </span><span class="NUMB">34</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1241</span> </span><span class="WHIT">  </span><span class="NAME">End</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">35</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1242</span> </span><span class="WHIT">  </span><span class="NAME">Home</span><span class="PUNC">:</span><span class="WHIT">          </span><span class="NUMB">36</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1243</span> </span><span class="WHIT">  </span><span class="NAME">Left</span><span class="PUNC">:</span><span class="WHIT">          </span><span class="NUMB">37</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1244</span> </span><span class="WHIT">  </span><span class="NAME">Up</span><span class="PUNC">:</span><span class="WHIT">            </span><span class="NUMB">38</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1245</span> </span><span class="WHIT">  </span><span class="NAME">Right</span><span class="PUNC">:</span><span class="WHIT">         </span><span class="NUMB">39</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1246</span> </span><span class="WHIT">  </span><span class="NAME">Down</span><span class="PUNC">:</span><span class="WHIT">          </span><span class="NUMB">40</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1247</span> </span><span class="WHIT">  </span><span class="NAME">PrintScreen</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NUMB">44</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1248</span> </span><span class="WHIT">  </span><span class="NAME">Insert</span><span class="PUNC">:</span><span class="WHIT">        </span><span class="NUMB">45</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1249</span> </span><span class="WHIT">  </span><span class="STRN">'Delete'</span><span class="PUNC">:</span><span class="WHIT">      </span><span class="NUMB">46</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1250</span> </span><span class="WHIT">  </span><span class="NAME">Win</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">91</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1251</span> </span><span class="WHIT">  </span><span class="NAME">ContextMenu</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NUMB">93</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1252</span> </span><span class="WHIT">  </span><span class="STRN">'*'</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">106</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1253</span> </span><span class="WHIT">  </span><span class="STRN">'+'</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">107</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1254</span> </span><span class="WHIT">  </span><span class="NAME">F1</span><span class="PUNC">:</span><span class="WHIT">            </span><span class="NUMB">112</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1255</span> </span><span class="WHIT">  </span><span class="NAME">F2</span><span class="PUNC">:</span><span class="WHIT">            </span><span class="NUMB">113</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1256</span> </span><span class="WHIT">  </span><span class="NAME">F3</span><span class="PUNC">:</span><span class="WHIT">            </span><span class="NUMB">114</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1257</span> </span><span class="WHIT">  </span><span class="NAME">F4</span><span class="PUNC">:</span><span class="WHIT">            </span><span class="NUMB">115</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1258</span> </span><span class="WHIT">  </span><span class="NAME">F5</span><span class="PUNC">:</span><span class="WHIT">            </span><span class="NUMB">116</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1259</span> </span><span class="WHIT">  </span><span class="NAME">F6</span><span class="PUNC">:</span><span class="WHIT">            </span><span class="NUMB">117</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1260</span> </span><span class="WHIT">  </span><span class="NAME">F7</span><span class="PUNC">:</span><span class="WHIT">            </span><span class="NUMB">118</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1261</span> </span><span class="WHIT">  </span><span class="NAME">F8</span><span class="PUNC">:</span><span class="WHIT">            </span><span class="NUMB">119</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1262</span> </span><span class="WHIT">  </span><span class="NAME">F9</span><span class="PUNC">:</span><span class="WHIT">            </span><span class="NUMB">120</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1263</span> </span><span class="WHIT">  </span><span class="NAME">F10</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">121</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1264</span> </span><span class="WHIT">  </span><span class="NAME">F11</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">122</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1265</span> </span><span class="WHIT">  </span><span class="NAME">F12</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">123</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1266</span> </span><span class="WHIT">  </span><span class="NAME">NumLock</span><span class="PUNC">:</span><span class="WHIT">       </span><span class="NUMB">144</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1267</span> </span><span class="WHIT">  </span><span class="STRN">';'</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">186</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1268</span> </span><span class="WHIT">  </span><span class="STRN">'='</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">187</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1269</span> </span><span class="WHIT">  </span><span class="STRN">','</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">188</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1270</span> </span><span class="WHIT">  </span><span class="STRN">'-'</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">189</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1271</span> </span><span class="WHIT">  </span><span class="STRN">'.'</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">190</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1272</span> </span><span class="WHIT">  </span><span class="STRN">'/'</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">191</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1273</span> </span><span class="WHIT">  </span><span class="STRN">'`'</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">192</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1274</span> </span><span class="WHIT">  </span><span class="STRN">'['</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">219</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1275</span> </span><span class="WHIT">  </span><span class="STRN">'\\'</span><span class="PUNC">:</span><span class="WHIT">          </span><span class="NUMB">220</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1276</span> </span><span class="WHIT">  </span><span class="STRN">']'</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">221</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1277</span> </span><span class="WHIT">  </span><span class="STRN">"'"</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">222</span><span class="WHIT">
<span class='line'>1278</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1279</span> 
<span class='line'>1280</span> </span><span class="COMM">/**
<span class='line'>1281</span>  * @namespace Holds the list of codes, each being associated to a virtual key 
<span class='line'>1282</span>  * identifier.
<span class='line'>1283</span>  *
<span class='line'>1284</span>  * @private
<span class='line'>1285</span>  */</span><span class="WHIT">
<span class='line'>1286</span> </span><span class="NAME">pwlib.dom.keyCodes</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1287</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1288</span>    * For almost each key code, these comments give the key name, the 
<span class='line'>1289</span>    * keyIdentifier from the DOM 3 Events spec and the Unicode character 
<span class='line'>1290</span>    * information (if you would use the decimal code for direct conversion to 
<span class='line'>1291</span>    * a character, e.g. String.fromCharCode()). Obviously, the Unicode character 
<span class='line'>1292</span>    * information is not to be used, since these are only virtual key codes (not 
<span class='line'>1293</span>    * really char codes) associated to key names.
<span class='line'>1294</span>    *
<span class='line'>1295</span>    * Each key name in here tries to follow the same style as the defined 
<span class='line'>1296</span>    * keyIdentifiers from the DOM 3 Events. Thus for the Page Down button, 
<span class='line'>1297</span>    * 'PageDown' is used (not other variations like 'pag-up'), and so on.
<span class='line'>1298</span>    *
<span class='line'>1299</span>    * Multiple key codes might be associated to the same key - it's not an error.
<span class='line'>1300</span>    *
<span class='line'>1301</span>    * Note that this list is not an exhaustive key codes list. This means that 
<span class='line'>1302</span>    * for key A or for key 0, the script will do String.fromCharCode(keyCode), to 
<span class='line'>1303</span>    * determine the key. For the case of alpha-numeric keys, this works fine.
<span class='line'>1304</span>    */</span><span class="WHIT">
<span class='line'>1305</span> 
<span class='line'>1306</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1307</span>    * Key: Enter
<span class='line'>1308</span>    * Unicode: U+0003 [End of text]
<span class='line'>1309</span>    *
<span class='line'>1310</span>    * Note 1: This keyCode is only used in Safari 2 (older Webkit) for the Enter 
<span class='line'>1311</span>    * key.
<span class='line'>1312</span>    *
<span class='line'>1313</span>    * Note 2: In Gecko this keyCode is used for the Cancel key (see 
<span class='line'>1314</span>    * DOM_VK_CANCEL).
<span class='line'>1315</span>    */</span><span class="WHIT">
<span class='line'>1316</span> </span><span class="WHIT">  </span><span class="NUMB">3</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Enter'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1317</span> 
<span class='line'>1318</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1319</span>    * Key: Help
<span class='line'>1320</span>    * Unicode: U+0006 [Acknowledge]
<span class='line'>1321</span>    *
<span class='line'>1322</span>    * Note: Taken from Gecko (DOM_VK_HELP).
<span class='line'>1323</span>    */</span><span class="WHIT">
<span class='line'>1324</span> </span><span class="WHIT">  </span><span class="NUMB">6</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Help'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1325</span> 
<span class='line'>1326</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1327</span>    * Key: Backspace
<span class='line'>1328</span>    * Unicode: U+0008 [Backspace]
<span class='line'>1329</span>    * keyIdentifier: U+0008
<span class='line'>1330</span>    */</span><span class="WHIT">
<span class='line'>1331</span> </span><span class="WHIT">  </span><span class="NUMB">8</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Backspace'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1332</span> 
<span class='line'>1333</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1334</span>    * Key: Tab
<span class='line'>1335</span>    * Unicode: U+0009 [Horizontal tab]
<span class='line'>1336</span>    * keyIdentifier: U+0009
<span class='line'>1337</span>    */</span><span class="WHIT">
<span class='line'>1338</span> </span><span class="WHIT">  </span><span class="NUMB">9</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Tab'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1339</span> 
<span class='line'>1340</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1341</span>    * Key: Enter
<span class='line'>1342</span>    * Unicode: U+0010 [Line feed (LF) / New line (NL) / End of line (EOL)]
<span class='line'>1343</span>    *
<span class='line'>1344</span>    * Note: Taken from the Unicode characters list. If it ends up as a keyCode in 
<span class='line'>1345</span>    * some event, it's simply considered as being the Enter key.
<span class='line'>1346</span>    */</span><span class="WHIT">
<span class='line'>1347</span> </span><span class="WHIT">  </span><span class="NUMB">10</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Enter'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1348</span> 
<span class='line'>1349</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1350</span>    * Key: NumPad_Center
<span class='line'>1351</span>    * Unicode: U+000C [Form feed]
<span class='line'>1352</span>    * keyIdentifier: Clear
<span class='line'>1353</span>    *
<span class='line'>1354</span>    * Note 1: This keyCode is used when NumLock is off, and the user pressed the 
<span class='line'>1355</span>    * 5 key on the numeric pad.
<span class='line'>1356</span>    *
<span class='line'>1357</span>    * Note 2: Safari 2 (older Webkit) assigns this keyCode to the NumLock key 
<span class='line'>1358</span>    * itself.
<span class='line'>1359</span>    */</span><span class="WHIT">
<span class='line'>1360</span> </span><span class="WHIT">  </span><span class="NUMB">12</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Clear'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1361</span> 
<span class='line'>1362</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1363</span>    * Key: Enter
<span class='line'>1364</span>    * Unicode: U+000D [Carriage return (CR)]
<span class='line'>1365</span>    * keyIdentifier: Enter
<span class='line'>1366</span>    *
<span class='line'>1367</span>    * Note 1: This is the keyCode used by most of the Web browsers when the Enter 
<span class='line'>1368</span>    * key is pressed.
<span class='line'>1369</span>    *
<span class='line'>1370</span>    * Note 2: Gecko associates the DOM_VK_RETURN to this keyCode.
<span class='line'>1371</span>    */</span><span class="WHIT">
<span class='line'>1372</span> </span><span class="WHIT">  </span><span class="NUMB">13</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Enter'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1373</span> 
<span class='line'>1374</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1375</span>    * Key: Enter
<span class='line'>1376</span>    * Unicode: U+000E [Shift out]
<span class='line'>1377</span>    *
<span class='line'>1378</span>    * Note: Taken from Gecko (DOM_VK_ENTER).
<span class='line'>1379</span>    */</span><span class="WHIT">
<span class='line'>1380</span> </span><span class="WHIT">  </span><span class="NUMB">14</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Enter'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1381</span> 
<span class='line'>1382</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1383</span>    * Key: Shift
<span class='line'>1384</span>    * Unicode: U+0010 [Data link escape]
<span class='line'>1385</span>    * keyIdentifier: Shift
<span class='line'>1386</span>    *
<span class='line'>1387</span>    * Note: In older Safari (Webkit) versions Shift+Tab is assigned a different 
<span class='line'>1388</span>    * keyCode: keyCode 25.
<span class='line'>1389</span>    */</span><span class="WHIT">
<span class='line'>1390</span> </span><span class="WHIT">  </span><span class="NUMB">16</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Shift'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1391</span> 
<span class='line'>1392</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1393</span>    * Key: Control
<span class='line'>1394</span>    * Unicode: U+0011 [Device control one]
<span class='line'>1395</span>    * keyIdentifier: Control
<span class='line'>1396</span>    */</span><span class="WHIT">
<span class='line'>1397</span> </span><span class="WHIT">  </span><span class="NUMB">17</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Control'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1398</span> 
<span class='line'>1399</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1400</span>    * Key: Alt
<span class='line'>1401</span>    * Unicode: U+0012 [Device control two]
<span class='line'>1402</span>    * keyIdentifier: Alt
<span class='line'>1403</span>    */</span><span class="WHIT">
<span class='line'>1404</span> </span><span class="WHIT">  </span><span class="NUMB">18</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Alt'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1405</span> 
<span class='line'>1406</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1407</span>    * Key: Pause
<span class='line'>1408</span>    * Unicode: U+0013 [Device control three]
<span class='line'>1409</span>    * keyIdentifier: Pause
<span class='line'>1410</span>    */</span><span class="WHIT">
<span class='line'>1411</span> </span><span class="WHIT">  </span><span class="NUMB">19</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Pause'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1412</span> 
<span class='line'>1413</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1414</span>    * Key: CapsLock
<span class='line'>1415</span>    * Unicode: U+0014 [Device control four]
<span class='line'>1416</span>    * keyIdentifier: CapsLock
<span class='line'>1417</span>    */</span><span class="WHIT">
<span class='line'>1418</span> </span><span class="WHIT">  </span><span class="NUMB">20</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'CapsLock'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1419</span> 
<span class='line'>1420</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1421</span>    * Key: Cancel
<span class='line'>1422</span>    * Unicode: U+0018 [Cancel]
<span class='line'>1423</span>    * keyIdentifier: U+0018
<span class='line'>1424</span>    */</span><span class="WHIT">
<span class='line'>1425</span> </span><span class="WHIT">  </span><span class="NUMB">24</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Cancel'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1426</span> 
<span class='line'>1427</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1428</span>    * Key: Escape
<span class='line'>1429</span>    * Unicode: U+001B [Escape]
<span class='line'>1430</span>    * keyIdentifier: U+001B
<span class='line'>1431</span>    */</span><span class="WHIT">
<span class='line'>1432</span> </span><span class="WHIT">  </span><span class="NUMB">27</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Escape'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1433</span> 
<span class='line'>1434</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1435</span>    * Key: Space
<span class='line'>1436</span>    * Unicode: U+0020 [Space]
<span class='line'>1437</span>    * keyIdentifier: U+0020
<span class='line'>1438</span>    */</span><span class="WHIT">
<span class='line'>1439</span> </span><span class="WHIT">  </span><span class="NUMB">32</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Space'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1440</span> 
<span class='line'>1441</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1442</span>    * Key: PageUp or NumPad_North_East
<span class='line'>1443</span>    * Unicode: U+0021 ! [Exclamation mark]
<span class='line'>1444</span>    * keyIdentifier: PageUp
<span class='line'>1445</span>    */</span><span class="WHIT">
<span class='line'>1446</span> </span><span class="WHIT">  </span><span class="NUMB">33</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'PageUp'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1447</span> 
<span class='line'>1448</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1449</span>    * Key: PageDown or NumPad_South_East
<span class='line'>1450</span>    * Unicode: U+0022 " [Quotation mark]
<span class='line'>1451</span>    * keyIdentifier: PageDown
<span class='line'>1452</span>    */</span><span class="WHIT">
<span class='line'>1453</span> </span><span class="WHIT">  </span><span class="NUMB">34</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'PageDown'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1454</span> 
<span class='line'>1455</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1456</span>    * Key: End or NumPad_South_West
<span class='line'>1457</span>    * Unicode: U+0023 # [Number sign]
<span class='line'>1458</span>    * keyIdentifier: PageDown
<span class='line'>1459</span>    */</span><span class="WHIT">
<span class='line'>1460</span> </span><span class="WHIT">  </span><span class="NUMB">35</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'End'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1461</span> 
<span class='line'>1462</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1463</span>    * Key: Home or NumPad_North_West
<span class='line'>1464</span>    * Unicode: U+0024 $ [Dollar sign]
<span class='line'>1465</span>    * keyIdentifier: Home
<span class='line'>1466</span>    */</span><span class="WHIT">
<span class='line'>1467</span> </span><span class="WHIT">  </span><span class="NUMB">36</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Home'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1468</span> 
<span class='line'>1469</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1470</span>    * Key: Left or NumPad_West
<span class='line'>1471</span>    * Unicode: U+0025 % [Percent sign]
<span class='line'>1472</span>    * keyIdentifier: Left
<span class='line'>1473</span>    */</span><span class="WHIT">
<span class='line'>1474</span> </span><span class="WHIT">  </span><span class="NUMB">37</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Left'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1475</span> 
<span class='line'>1476</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1477</span>    * Key: Up or NumPad_North
<span class='line'>1478</span>    * Unicode: U+0026 & [Ampersand]
<span class='line'>1479</span>    * keyIdentifier: Up
<span class='line'>1480</span>    */</span><span class="WHIT">
<span class='line'>1481</span> </span><span class="WHIT">  </span><span class="NUMB">38</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Up'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1482</span> 
<span class='line'>1483</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1484</span>    * Key: Right or NumPad_East
<span class='line'>1485</span>    * Unicode: U+0027 ' [Apostrophe]
<span class='line'>1486</span>    * keyIdentifier: Right
<span class='line'>1487</span>    */</span><span class="WHIT">
<span class='line'>1488</span> </span><span class="WHIT">  </span><span class="NUMB">39</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Right'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1489</span> 
<span class='line'>1490</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1491</span>    * Key: Down or NumPad_South
<span class='line'>1492</span>    * Unicode: U+0028 ( [Left parenthesis]
<span class='line'>1493</span>    * keyIdentifier: Down
<span class='line'>1494</span>    */</span><span class="WHIT">
<span class='line'>1495</span> </span><span class="WHIT">  </span><span class="NUMB">40</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Down'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1496</span> 
<span class='line'>1497</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1498</span>    * Key: PrintScreen
<span class='line'>1499</span>    * Unicode: U+002C , [Comma]
<span class='line'>1500</span>    * keyIdentifier: PrintScreen
<span class='line'>1501</span>    */</span><span class="WHIT">
<span class='line'>1502</span> </span><span class="WHIT">  </span><span class="COMM">//44: 'PrintScreen',</span><span class="WHIT">
<span class='line'>1503</span> 
<span class='line'>1504</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1505</span>    * Key: Insert or NumPad_Insert
<span class='line'>1506</span>    * Unicode: U+002D - [Hyphen-Minus]
<span class='line'>1507</span>    * keyIdentifier: Insert
<span class='line'>1508</span>    */</span><span class="WHIT">
<span class='line'>1509</span> </span><span class="WHIT">  </span><span class="NUMB">45</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Insert'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1510</span> 
<span class='line'>1511</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1512</span>    * Key: Delete or NumPad_Delete
<span class='line'>1513</span>    * Unicode: U+002E . [Full stop / period]
<span class='line'>1514</span>    * keyIdentifier: U+007F
<span class='line'>1515</span>    */</span><span class="WHIT">
<span class='line'>1516</span> </span><span class="WHIT">  </span><span class="NUMB">46</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Delete'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1517</span> 
<span class='line'>1518</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1519</span>    * Key: WinLeft
<span class='line'>1520</span>    * Unicode: U+005B [ [Left square bracket]
<span class='line'>1521</span>    * keyIdentifier: Win
<span class='line'>1522</span>    *
<span class='line'>1523</span>    * Disabled: rarely needed.
<span class='line'>1524</span>    */</span><span class="WHIT">
<span class='line'>1525</span> </span><span class="WHIT">  </span><span class="COMM">//91: 'Win',</span><span class="WHIT">
<span class='line'>1526</span> 
<span class='line'>1527</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1528</span>    * Key: WinRight
<span class='line'>1529</span>    * Unicode: U+005C \ [Reverse solidus / Backslash]
<span class='line'>1530</span>    * keyIdentifier: Win
<span class='line'>1531</span>    */</span><span class="WHIT">
<span class='line'>1532</span> </span><span class="WHIT">  </span><span class="COMM">//92: 'Win',</span><span class="WHIT">
<span class='line'>1533</span> 
<span class='line'>1534</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1535</span>    * Key: Menu/ContextMenu
<span class='line'>1536</span>    * Unicode: U+005D ] [Right square bracket]
<span class='line'>1537</span>    * keyIdentifier: ...
<span class='line'>1538</span>    *
<span class='line'>1539</span>    * Disabled: Is it Meta? Is it Menu, ContextMenu, what? Too much mess.
<span class='line'>1540</span>    */</span><span class="WHIT">
<span class='line'>1541</span> </span><span class="WHIT">  </span><span class="COMM">//93: 'ContextMenu',</span><span class="WHIT">
<span class='line'>1542</span> 
<span class='line'>1543</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1544</span>    * Key: NumPad_0
<span class='line'>1545</span>    * Unicode: U+0060 ` [Grave accent]
<span class='line'>1546</span>    * keyIdentifier: 0
<span class='line'>1547</span>    */</span><span class="WHIT">
<span class='line'>1548</span> </span><span class="WHIT">  </span><span class="NUMB">96</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'0'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1549</span> 
<span class='line'>1550</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1551</span>    * Key: NumPad_1
<span class='line'>1552</span>    * Unicode: U+0061 a [Latin small letter a]
<span class='line'>1553</span>    * keyIdentifier: 1
<span class='line'>1554</span>    */</span><span class="WHIT">
<span class='line'>1555</span> </span><span class="WHIT">  </span><span class="NUMB">97</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'1'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1556</span> 
<span class='line'>1557</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1558</span>    * Key: NumPad_2
<span class='line'>1559</span>    * Unicode: U+0062 b [Latin small letter b]
<span class='line'>1560</span>    * keyIdentifier: 2
<span class='line'>1561</span>    */</span><span class="WHIT">
<span class='line'>1562</span> </span><span class="WHIT">  </span><span class="NUMB">98</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'2'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1563</span> 
<span class='line'>1564</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1565</span>    * Key: NumPad_3
<span class='line'>1566</span>    * Unicode: U+0063 c [Latin small letter c]
<span class='line'>1567</span>    * keyIdentifier: 3
<span class='line'>1568</span>    */</span><span class="WHIT">
<span class='line'>1569</span> </span><span class="WHIT">  </span><span class="NUMB">99</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'3'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1570</span> 
<span class='line'>1571</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1572</span>    * Key: NumPad_4
<span class='line'>1573</span>    * Unicode: U+0064 d [Latin small letter d]
<span class='line'>1574</span>    * keyIdentifier: 4
<span class='line'>1575</span>    */</span><span class="WHIT">
<span class='line'>1576</span> </span><span class="WHIT">  </span><span class="NUMB">100</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'4'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1577</span> 
<span class='line'>1578</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1579</span>    * Key: NumPad_5
<span class='line'>1580</span>    * Unicode: U+0065 e [Latin small letter e]
<span class='line'>1581</span>    * keyIdentifier: 5
<span class='line'>1582</span>    */</span><span class="WHIT">
<span class='line'>1583</span> </span><span class="WHIT">  </span><span class="NUMB">101</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'5'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1584</span> 
<span class='line'>1585</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1586</span>    * Key: NumPad_6
<span class='line'>1587</span>    * Unicode: U+0066 f [Latin small letter f]
<span class='line'>1588</span>    * keyIdentifier: 6
<span class='line'>1589</span>    */</span><span class="WHIT">
<span class='line'>1590</span> </span><span class="WHIT">  </span><span class="NUMB">102</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'6'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1591</span> 
<span class='line'>1592</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1593</span>    * Key: NumPad_7
<span class='line'>1594</span>    * Unicode: U+0067 g [Latin small letter g]
<span class='line'>1595</span>    * keyIdentifier: 7
<span class='line'>1596</span>    */</span><span class="WHIT">
<span class='line'>1597</span> </span><span class="WHIT">  </span><span class="NUMB">103</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'7'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1598</span> 
<span class='line'>1599</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1600</span>    * Key: NumPad_8
<span class='line'>1601</span>    * Unicode: U+0068 h [Latin small letter h]
<span class='line'>1602</span>    * keyIdentifier: 8
<span class='line'>1603</span>    */</span><span class="WHIT">
<span class='line'>1604</span> </span><span class="WHIT">  </span><span class="NUMB">104</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'8'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1605</span> 
<span class='line'>1606</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1607</span>    * Key: NumPad_9
<span class='line'>1608</span>    * Unicode: U+0069 i [Latin small letter i]
<span class='line'>1609</span>    * keyIdentifier: 9
<span class='line'>1610</span>    */</span><span class="WHIT">
<span class='line'>1611</span> </span><span class="WHIT">  </span><span class="NUMB">105</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'9'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1612</span> 
<span class='line'>1613</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1614</span>    * Key: NumPad_Multiply
<span class='line'>1615</span>    * Unicode: U+0070 j [Latin small letter j]
<span class='line'>1616</span>    * keyIdentifier: U+002A * [Asterisk / Star]
<span class='line'>1617</span>    */</span><span class="WHIT">
<span class='line'>1618</span> </span><span class="WHIT">  </span><span class="NUMB">106</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'*'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1619</span> 
<span class='line'>1620</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1621</span>    * Key: NumPad_Plus
<span class='line'>1622</span>    * Unicode: U+0071 k [Latin small letter k]
<span class='line'>1623</span>    * keyIdentifier: U+002B + [Plus]
<span class='line'>1624</span>    */</span><span class="WHIT">
<span class='line'>1625</span> </span><span class="WHIT">  </span><span class="NUMB">107</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'+'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1626</span> 
<span class='line'>1627</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1628</span>    * Key: NumPad_Minus
<span class='line'>1629</span>    * Unicode: U+0073 m [Latin small letter m]
<span class='line'>1630</span>    * keyIdentifier: U+002D + [Hyphen / Minus]
<span class='line'>1631</span>    */</span><span class="WHIT">
<span class='line'>1632</span> </span><span class="WHIT">  </span><span class="NUMB">109</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'-'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1633</span> 
<span class='line'>1634</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1635</span>    * Key: NumPad_Period
<span class='line'>1636</span>    * Unicode: U+0074 n [Latin small letter n]
<span class='line'>1637</span>    * keyIdentifier: U+002E . [Period]
<span class='line'>1638</span>    */</span><span class="WHIT">
<span class='line'>1639</span> </span><span class="WHIT">  </span><span class="NUMB">110</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'.'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1640</span> 
<span class='line'>1641</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1642</span>    * Key: NumPad_Division
<span class='line'>1643</span>    * Unicode: U+0075 o [Latin small letter o]
<span class='line'>1644</span>    * keyIdentifier: U+002F / [Solidus / Slash]
<span class='line'>1645</span>    */</span><span class="WHIT">
<span class='line'>1646</span> </span><span class="WHIT">  </span><span class="NUMB">111</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'/'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1647</span> 
<span class='line'>1648</span> </span><span class="WHIT">  </span><span class="NUMB">112</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F1'</span><span class="PUNC">,</span><span class="WHIT">                </span><span class="COMM">// p</span><span class="WHIT">
<span class='line'>1649</span> </span><span class="WHIT">  </span><span class="NUMB">113</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F2'</span><span class="PUNC">,</span><span class="WHIT">                </span><span class="COMM">// q</span><span class="WHIT">
<span class='line'>1650</span> </span><span class="WHIT">  </span><span class="NUMB">114</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F3'</span><span class="PUNC">,</span><span class="WHIT">                </span><span class="COMM">// r</span><span class="WHIT">
<span class='line'>1651</span> </span><span class="WHIT">  </span><span class="NUMB">115</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F4'</span><span class="PUNC">,</span><span class="WHIT">                </span><span class="COMM">// s</span><span class="WHIT">
<span class='line'>1652</span> </span><span class="WHIT">  </span><span class="NUMB">116</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F5'</span><span class="PUNC">,</span><span class="WHIT">                </span><span class="COMM">// t</span><span class="WHIT">
<span class='line'>1653</span> </span><span class="WHIT">  </span><span class="NUMB">117</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F6'</span><span class="PUNC">,</span><span class="WHIT">                </span><span class="COMM">// u</span><span class="WHIT">
<span class='line'>1654</span> </span><span class="WHIT">  </span><span class="NUMB">118</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F7'</span><span class="PUNC">,</span><span class="WHIT">                </span><span class="COMM">// v</span><span class="WHIT">
<span class='line'>1655</span> </span><span class="WHIT">  </span><span class="NUMB">119</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F8'</span><span class="PUNC">,</span><span class="WHIT">                </span><span class="COMM">// w</span><span class="WHIT">
<span class='line'>1656</span> </span><span class="WHIT">  </span><span class="NUMB">120</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F9'</span><span class="PUNC">,</span><span class="WHIT">                </span><span class="COMM">// x</span><span class="WHIT">
<span class='line'>1657</span> </span><span class="WHIT">  </span><span class="NUMB">121</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F10'</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// y</span><span class="WHIT">
<span class='line'>1658</span> </span><span class="WHIT">  </span><span class="NUMB">122</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F11'</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// z</span><span class="WHIT">
<span class='line'>1659</span> </span><span class="WHIT">  </span><span class="NUMB">123</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F12'</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// {</span><span class="WHIT">
<span class='line'>1660</span> 
<span class='line'>1661</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1662</span>    * Key: Delete
<span class='line'>1663</span>    * Unicode: U+007F [Delete]
<span class='line'>1664</span>    * keyIdentifier: U+007F
<span class='line'>1665</span>    */</span><span class="WHIT">
<span class='line'>1666</span> </span><span class="WHIT">  </span><span class="NUMB">127</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Delete'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1667</span> 
<span class='line'>1668</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1669</span>    * Key: NumLock
<span class='line'>1670</span>    * Unicode: U+0090 [Device control string]
<span class='line'>1671</span>    * keyIdentifier: NumLock
<span class='line'>1672</span>    */</span><span class="WHIT">
<span class='line'>1673</span> </span><span class="WHIT">  </span><span class="NUMB">144</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'NumLock'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1674</span> 
<span class='line'>1675</span> </span><span class="WHIT">  </span><span class="NUMB">186</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">';'</span><span class="PUNC">,</span><span class="WHIT">                 </span><span class="COMM">// º (Masculine ordinal indicator)</span><span class="WHIT">
<span class='line'>1676</span> </span><span class="WHIT">  </span><span class="NUMB">187</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'='</span><span class="PUNC">,</span><span class="WHIT">                 </span><span class="COMM">// »</span><span class="WHIT">
<span class='line'>1677</span> </span><span class="WHIT">  </span><span class="NUMB">188</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">','</span><span class="PUNC">,</span><span class="WHIT">                 </span><span class="COMM">// ¼</span><span class="WHIT">
<span class='line'>1678</span> </span><span class="WHIT">  </span><span class="NUMB">189</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'-'</span><span class="PUNC">,</span><span class="WHIT">                 </span><span class="COMM">// ½</span><span class="WHIT">
<span class='line'>1679</span> </span><span class="WHIT">  </span><span class="NUMB">190</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'.'</span><span class="PUNC">,</span><span class="WHIT">                 </span><span class="COMM">// ¾</span><span class="WHIT">
<span class='line'>1680</span> </span><span class="WHIT">  </span><span class="NUMB">191</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'/'</span><span class="PUNC">,</span><span class="WHIT">                 </span><span class="COMM">// ¿</span><span class="WHIT">
<span class='line'>1681</span> </span><span class="WHIT">  </span><span class="NUMB">192</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'`'</span><span class="PUNC">,</span><span class="WHIT">                 </span><span class="COMM">// À</span><span class="WHIT">
<span class='line'>1682</span> </span><span class="WHIT">  </span><span class="NUMB">219</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'['</span><span class="PUNC">,</span><span class="WHIT">                 </span><span class="COMM">// Û</span><span class="WHIT">
<span class='line'>1683</span> </span><span class="WHIT">  </span><span class="NUMB">220</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'\\'</span><span class="PUNC">,</span><span class="WHIT">                </span><span class="COMM">// Ü</span><span class="WHIT">
<span class='line'>1684</span> </span><span class="WHIT">  </span><span class="NUMB">221</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">']'</span><span class="PUNC">,</span><span class="WHIT">                 </span><span class="COMM">// Ý</span><span class="WHIT">
<span class='line'>1685</span> </span><span class="WHIT">  </span><span class="NUMB">222</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"'"</span><span class="WHIT">                  </span><span class="COMM">// Þ (Latin capital letter thorn)</span><span class="WHIT">
<span class='line'>1686</span> 
<span class='line'>1687</span> </span><span class="WHIT">  </span><span class="COMM">//224: 'Win',               // à</span><span class="WHIT">
<span class='line'>1688</span> </span><span class="WHIT">  </span><span class="COMM">//229: 'WinIME',            // å or WinIME or something else in Webkit</span><span class="WHIT">
<span class='line'>1689</span> </span><span class="WHIT">  </span><span class="COMM">//255: 'NumLock',           // ÿ, Gecko and Chrome, Windows XP in VirtualBox</span><span class="WHIT">
<span class='line'>1690</span> </span><span class="WHIT">  </span><span class="COMM">//376: 'NumLock'            // Ÿ, Opera, Windows XP in VirtualBox</span><span class="WHIT">
<span class='line'>1691</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1692</span> 
<span class='line'>1693</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pwlib.browser.gecko</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1694</span> </span><span class="WHIT">  </span><span class="NAME">pwlib.dom.keyCodes</span><span class="PUNC">[</span><span class="NUMB">3</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'Cancel'</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// DOM_VK_CANCEL</span><span class="WHIT">
<span class='line'>1695</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1696</span> 
<span class='line'>1697</span> </span><span class="COMM">/**
<span class='line'>1698</span>  * @namespace Holds a list of common wrong key codes in Web browsers.
<span class='line'>1699</span>  *
<span class='line'>1700</span>  * @private
<span class='line'>1701</span>  */</span><span class="WHIT">
<span class='line'>1702</span> </span><span class="NAME">pwlib.dom.keyCodes_fixes</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1703</span> </span><span class="WHIT">  </span><span class="NUMB">42</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NAME">pwlib.dom.keyNames</span><span class="PUNC">[</span><span class="STRN">'*'</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">        </span><span class="COMM">// char * to key *</span><span class="WHIT">
<span class='line'>1704</span> </span><span class="WHIT">  </span><span class="NUMB">47</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NAME">pwlib.dom.keyNames</span><span class="PUNC">[</span><span class="STRN">'/'</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">        </span><span class="COMM">// char / to key /</span><span class="WHIT">
<span class='line'>1705</span> </span><span class="WHIT">  </span><span class="NUMB">59</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NAME">pwlib.dom.keyNames</span><span class="PUNC">[</span><span class="STRN">';'</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">        </span><span class="COMM">// char ; to key ;</span><span class="WHIT">
<span class='line'>1706</span> </span><span class="WHIT">  </span><span class="NUMB">61</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NAME">pwlib.dom.keyNames</span><span class="PUNC">[</span><span class="STRN">'='</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">        </span><span class="COMM">// char = to key =</span><span class="WHIT">
<span class='line'>1707</span> </span><span class="WHIT">  </span><span class="NUMB">96</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NUMB">48</span><span class="PUNC">,</span><span class="WHIT">                             </span><span class="COMM">// NumPad_0 to char 0</span><span class="WHIT">
<span class='line'>1708</span> </span><span class="WHIT">  </span><span class="NUMB">97</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NUMB">49</span><span class="PUNC">,</span><span class="WHIT">                             </span><span class="COMM">// NumPad_1 to char 1</span><span class="WHIT">
<span class='line'>1709</span> </span><span class="WHIT">  </span><span class="NUMB">98</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NUMB">50</span><span class="PUNC">,</span><span class="WHIT">                             </span><span class="COMM">// NumPad_2 to char 2</span><span class="WHIT">
<span class='line'>1710</span> </span><span class="WHIT">  </span><span class="NUMB">99</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NUMB">51</span><span class="PUNC">,</span><span class="WHIT">                             </span><span class="COMM">// NumPad_3 to char 3</span><span class="WHIT">
<span class='line'>1711</span> </span><span class="WHIT">  </span><span class="NUMB">100</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NUMB">52</span><span class="PUNC">,</span><span class="WHIT">                             </span><span class="COMM">// NumPad_4 to char 4</span><span class="WHIT">
<span class='line'>1712</span> </span><span class="WHIT">  </span><span class="NUMB">101</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NUMB">53</span><span class="PUNC">,</span><span class="WHIT">                             </span><span class="COMM">// NumPad_5 to char 5</span><span class="WHIT">
<span class='line'>1713</span> </span><span class="WHIT">  </span><span class="NUMB">102</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NUMB">54</span><span class="PUNC">,</span><span class="WHIT">                             </span><span class="COMM">// NumPad_6 to char 6</span><span class="WHIT">
<span class='line'>1714</span> </span><span class="WHIT">  </span><span class="NUMB">103</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NUMB">55</span><span class="PUNC">,</span><span class="WHIT">                             </span><span class="COMM">// NumPad_7 to char 7</span><span class="WHIT">
<span class='line'>1715</span> </span><span class="WHIT">  </span><span class="NUMB">104</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NUMB">56</span><span class="PUNC">,</span><span class="WHIT">                             </span><span class="COMM">// NumPad_8 to char 8</span><span class="WHIT">
<span class='line'>1716</span> </span><span class="WHIT">  </span><span class="NUMB">105</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NUMB">57</span><span class="PUNC">,</span><span class="WHIT">                             </span><span class="COMM">// NumPad_9 to char 9</span><span class="WHIT">
<span class='line'>1717</span> </span><span class="WHIT">  </span><span class="COMM">//106:  56,                           // NumPad_Multiply to char 8</span><span class="WHIT">
<span class='line'>1718</span> </span><span class="WHIT">  </span><span class="COMM">//107:  187,                          // NumPad_Plus to key =</span><span class="WHIT">
<span class='line'>1719</span> </span><span class="WHIT">  </span><span class="NUMB">109</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NAME">pwlib.dom.keyNames</span><span class="PUNC">[</span><span class="STRN">'-'</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">        </span><span class="COMM">// NumPad_Minus to key -</span><span class="WHIT">
<span class='line'>1720</span> </span><span class="WHIT">  </span><span class="NUMB">110</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NAME">pwlib.dom.keyNames</span><span class="PUNC">[</span><span class="STRN">'.'</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">        </span><span class="COMM">// NumPad_Period to key .</span><span class="WHIT">
<span class='line'>1721</span> </span><span class="WHIT">  </span><span class="NUMB">111</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NAME">pwlib.dom.keyNames</span><span class="PUNC">[</span><span class="STRN">'/'</span><span class="PUNC">]</span><span class="WHIT">         </span><span class="COMM">// NumPad_Division to key /</span><span class="WHIT">
<span class='line'>1722</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1723</span> 
<span class='line'>1724</span> </span><span class="COMM">/**
<span class='line'>1725</span>  * @namespace Holds the list of broken key codes generated by older Webkit 
<span class='line'>1726</span>  * (Safari 2).
<span class='line'>1727</span>  *
<span class='line'>1728</span>  * @private
<span class='line'>1729</span>  */</span><span class="WHIT">
<span class='line'>1730</span> </span><span class="NAME">pwlib.dom.keyCodes_Safari2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1731</span> </span><span class="WHIT">  </span><span class="NUMB">63232</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.Up</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// 38</span><span class="WHIT">
<span class='line'>1732</span> </span><span class="WHIT">  </span><span class="NUMB">63233</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.Down</span><span class="PUNC">,</span><span class="WHIT">             </span><span class="COMM">// 40</span><span class="WHIT">
<span class='line'>1733</span> </span><span class="WHIT">  </span><span class="NUMB">63234</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.Left</span><span class="PUNC">,</span><span class="WHIT">             </span><span class="COMM">// 37</span><span class="WHIT">
<span class='line'>1734</span> </span><span class="WHIT">  </span><span class="NUMB">63235</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.Right</span><span class="PUNC">,</span><span class="WHIT">            </span><span class="COMM">// 39</span><span class="WHIT">
<span class='line'>1735</span> </span><span class="WHIT">  </span><span class="NUMB">63236</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.F1</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// 112</span><span class="WHIT">
<span class='line'>1736</span> </span><span class="WHIT">  </span><span class="NUMB">63237</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.F2</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// 113</span><span class="WHIT">
<span class='line'>1737</span> </span><span class="WHIT">  </span><span class="NUMB">63238</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.F3</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// 114</span><span class="WHIT">
<span class='line'>1738</span> </span><span class="WHIT">  </span><span class="NUMB">63239</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.F4</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// 115</span><span class="WHIT">
<span class='line'>1739</span> </span><span class="WHIT">  </span><span class="NUMB">63240</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.F5</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// 116</span><span class="WHIT">
<span class='line'>1740</span> </span><span class="WHIT">  </span><span class="NUMB">63241</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.F6</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// 117</span><span class="WHIT">
<span class='line'>1741</span> </span><span class="WHIT">  </span><span class="NUMB">63242</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.F7</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// 118</span><span class="WHIT">
<span class='line'>1742</span> </span><span class="WHIT">  </span><span class="NUMB">63243</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.F8</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// 119</span><span class="WHIT">
<span class='line'>1743</span> </span><span class="WHIT">  </span><span class="NUMB">63244</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.F9</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// 120</span><span class="WHIT">
<span class='line'>1744</span> </span><span class="WHIT">  </span><span class="NUMB">63245</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.F10</span><span class="PUNC">,</span><span class="WHIT">              </span><span class="COMM">// 121</span><span class="WHIT">
<span class='line'>1745</span> </span><span class="WHIT">  </span><span class="NUMB">63246</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.F11</span><span class="PUNC">,</span><span class="WHIT">              </span><span class="COMM">// 122</span><span class="WHIT">
<span class='line'>1746</span> </span><span class="WHIT">  </span><span class="NUMB">63247</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.F12</span><span class="PUNC">,</span><span class="WHIT">              </span><span class="COMM">// 123</span><span class="WHIT">
<span class='line'>1747</span> </span><span class="WHIT">  </span><span class="NUMB">63248</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.PrintScreen</span><span class="PUNC">,</span><span class="WHIT">      </span><span class="COMM">// 44</span><span class="WHIT">
<span class='line'>1748</span> </span><span class="WHIT">  </span><span class="NUMB">63272</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames</span><span class="PUNC">[</span><span class="STRN">'Delete'</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">        </span><span class="COMM">// 46</span><span class="WHIT">
<span class='line'>1749</span> </span><span class="WHIT">  </span><span class="NUMB">63273</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.Home</span><span class="PUNC">,</span><span class="WHIT">             </span><span class="COMM">// 36</span><span class="WHIT">
<span class='line'>1750</span> </span><span class="WHIT">  </span><span class="NUMB">63275</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.End</span><span class="PUNC">,</span><span class="WHIT">              </span><span class="COMM">// 35</span><span class="WHIT">
<span class='line'>1751</span> </span><span class="WHIT">  </span><span class="NUMB">63276</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.PageUp</span><span class="PUNC">,</span><span class="WHIT">           </span><span class="COMM">// 33</span><span class="WHIT">
<span class='line'>1752</span> </span><span class="WHIT">  </span><span class="NUMB">63277</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.PageDown</span><span class="PUNC">,</span><span class="WHIT">         </span><span class="COMM">// 34</span><span class="WHIT">
<span class='line'>1753</span> </span><span class="WHIT">  </span><span class="NUMB">63289</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.NumLock</span><span class="PUNC">,</span><span class="WHIT">          </span><span class="COMM">// 144</span><span class="WHIT">
<span class='line'>1754</span> </span><span class="WHIT">  </span><span class="NUMB">63302</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.Insert</span><span class="WHIT">            </span><span class="COMM">// 45</span><span class="WHIT">
<span class='line'>1755</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1756</span> 
<span class='line'>1757</span> 
<span class='line'>1758</span> </span><span class="COMM">/**
<span class='line'>1759</span>  * A complete keyboard events cross-browser compatibility layer.
<span class='line'>1760</span>  *
<span class='line'>1761</span>  * &lt;p>Unfortunately, due to the important differences across Web browsers, 
<span class='line'>1762</span>  * simply using the available properties in a single keyboard event is not 
<span class='line'>1763</span>  * enough to accurately determine the key the user pressed. Thus, one needs to 
<span class='line'>1764</span>  * have event handlers for all keyboard-related events &lt;code>keydown&lt;/code>, 
<span class='line'>1765</span>  * &lt;code>keypress&lt;/code> and &lt;code>keyup&lt;/code>.
<span class='line'>1766</span>  *
<span class='line'>1767</span>  * &lt;p>This class provides a complete keyboard event compatibility layer. For any 
<span class='line'>1768</span>  * new instance you provide the DOM element you want to listen events for, and 
<span class='line'>1769</span>  * the event handlers for any of the three events &lt;code>keydown&lt;/code> 
<span class='line'>1770</span>  * / &lt;code>keypress&lt;/code> / &lt;code>keyup&lt;/code>.
<span class='line'>1771</span>  *
<span class='line'>1772</span>  * &lt;p>Your event handlers will receive the original DOM Event object, with 
<span class='line'>1773</span>  * several new properties defined:
<span class='line'>1774</span>  *
<span class='line'>1775</span>  * &lt;ul>
<span class='line'>1776</span>  *   &lt;li>&lt;var>event.keyCode_&lt;/var> holds the correct code for event key.
<span class='line'>1777</span>  *
<span class='line'>1778</span>  *   &lt;li>&lt;var>event.key_&lt;/var> holds the key the user pressed. It can be either 
<span class='line'>1779</span>  *   a key name like "PageDown", "Delete", "Enter", or it is a character like 
<span class='line'>1780</span>  *   "A", "1", or "[".
<span class='line'>1781</span>  *
<span class='line'>1782</span>  *   &lt;li>&lt;var>event.charCode_&lt;/var> holds the Unicode character decimal code.
<span class='line'>1783</span>  *
<span class='line'>1784</span>  *   &lt;li>&lt;var>event.char_&lt;/var> holds the character generated by the event.
<span class='line'>1785</span>  *
<span class='line'>1786</span>  *   &lt;li>&lt;var>event.repeat_&lt;/var> is a boolean property telling if the 
<span class='line'>1787</span>  *   &lt;code>keypress&lt;/code> event is repeated - the user is holding down the key 
<span class='line'>1788</span>  *   for a long-enough period of time to generate multiple events.
<span class='line'>1789</span>  * &lt;/ul>
<span class='line'>1790</span>  *
<span class='line'>1791</span>  * &lt;p>The character-related properties, &lt;var>charCode_&lt;/var> and 
<span class='line'>1792</span>  * &lt;var>char_&lt;/var> are only available in the &lt;code>keypress&lt;/code> and 
<span class='line'>1793</span>  * &lt;code>keyup&lt;/code> event objects.
<span class='line'>1794</span>  *
<span class='line'>1795</span>  * &lt;p>This class will ensure that the &lt;code>keypress&lt;/code> event is always 
<span class='line'>1796</span>  * fired in Webkit and MSIE for all keys, except modifiers. For modifier keys 
<span class='line'>1797</span>  * like &lt;kbd>Shift&lt;/kbd>, &lt;kbd>Control&lt;/kbd>, and &lt;kbd>Alt&lt;/kbd>, the 
<span class='line'>1798</span>  * &lt;code>keypress&lt;/code> event will not be fired, even if the Web browser does 
<span class='line'>1799</span>  * it.
<span class='line'>1800</span>  *
<span class='line'>1801</span>  * &lt;p>Some user agents like Webkit repeat the &lt;code>keydown&lt;/code> event while 
<span class='line'>1802</span>  * the user holds down a key. This class will ensure that only the 
<span class='line'>1803</span>  * &lt;code>keypress&lt;/code> event is repeated.
<span class='line'>1804</span>  *
<span class='line'>1805</span>  * &lt;p>If you want to prevent the default action for an event, you should prevent 
<span class='line'>1806</span>  * it on &lt;code>keypress&lt;/code>. This class will prevent the default action for 
<span class='line'>1807</span>  * &lt;code>keydown&lt;/code> if need (in MSIE).
<span class='line'>1808</span>  *
<span class='line'>1809</span>  * @example
<span class='line'>1810</span>  * &lt;code>var &lt;var>klogger&lt;/var> = function (&lt;var>ev&lt;/var>) {
<span class='line'>1811</span>  *   console.log(&lt;var>ev&lt;/var>.type +
<span class='line'>1812</span>  *     ' keyCode_ ' + &lt;var>ev&lt;/var>.keyCode_ +
<span class='line'>1813</span>  *     ' key_ ' + &lt;var>ev&lt;/var>.key_ +
<span class='line'>1814</span>  *     ' charCode_ ' + &lt;var>ev&lt;/var>.charCode_ +
<span class='line'>1815</span>  *     ' char_ ' + &lt;var>ev&lt;/var>.char_ +
<span class='line'>1816</span>  *     ' repeat_ ' + &lt;var>ev&lt;/var>.repeat_);
<span class='line'>1817</span>  * };
<span class='line'>1818</span>  *
<span class='line'>1819</span>  * var &lt;var>kbListener&lt;/var> = new pwlib.dom.KeyboardEventListener(window,
<span class='line'>1820</span>  *               {keydown: &lt;var>klogger&lt;/var>,
<span class='line'>1821</span>  *                keypress: &lt;var>klogger&lt;/var>,
<span class='line'>1822</span>  *                keyup: &lt;var>klogger&lt;/var>});&lt;/code>
<span class='line'>1823</span>  *
<span class='line'>1824</span>  * // later when you're done...
<span class='line'>1825</span>  * &lt;code>&lt;var>kbListener&lt;/var>.detach();&lt;/code>
<span class='line'>1826</span>  *
<span class='line'>1827</span>  * @class A complete keyboard events cross-browser compatibility layer.
<span class='line'>1828</span>  *
<span class='line'>1829</span>  * @param {Element} elem_ The DOM Element you want to listen events for.
<span class='line'>1830</span>  *
<span class='line'>1831</span>  * @param {Object} handlers_ The object holding the list of event handlers 
<span class='line'>1832</span>  * associated to the name of each keyboard event you want to listen. To listen 
<span class='line'>1833</span>  * for all the three keyboard events use &lt;code>{keydown: &lt;var>fn1&lt;/var>, 
<span class='line'>1834</span>  * keypress: &lt;var>fn2&lt;/var>, keyup: &lt;var>fn3&lt;/var>}&lt;/code>.
<span class='line'>1835</span>  *
<span class='line'>1836</span>  * @throws {TypeError} If the &lt;var>handlers_&lt;/var> object does not contain any 
<span class='line'>1837</span>  * event handler.
<span class='line'>1838</span>  */</span><span class="WHIT">
<span class='line'>1839</span> </span><span class="NAME">pwlib.dom.KeyboardEventListener</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem_</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">handlers_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1840</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1841</span>     Technical details:
<span class='line'>1842</span> 
<span class='line'>1843</span>     For the keyup and keydown events the keyCode provided is that of the virtual 
<span class='line'>1844</span>     key irrespective of other modifiers (e.g. Shift). Generally, during the 
<span class='line'>1845</span>     keypress event, the keyCode holds the Unicode value of the character 
<span class='line'>1846</span>     resulted from the key press, say an alphabetic upper/lower-case char, 
<span class='line'>1847</span>     depending on the actual intent of the user and depending on the currently 
<span class='line'>1848</span>     active keyboard layout.
<span class='line'>1849</span> 
<span class='line'>1850</span>     Examples:
<span class='line'>1851</span>     * Pressing p you get keyCode 80 in keyup/keydown, and keyCode 112 in 
<span class='line'>1852</span>     keypress.  String.fromCharCode(80) = 'P' and String.fromCharCode(112) = 'p'.
<span class='line'>1853</span>     * Pressing P you get keyCode 80 in all events.
<span class='line'>1854</span>     * Pressing F1 you get keyCode 112 in keyup, keydown and keypress.
<span class='line'>1855</span>     * Pressing 9 you get keyCode 57 in all events.
<span class='line'>1856</span>     * Pressing Shift+9 you get keyCode 57 in keyup/keydown, and keyCode 40 in 
<span class='line'>1857</span>     keypress. String.fromCharCode(57) = '9' and String.fromCharCode(40) = '('.
<span class='line'>1858</span> 
<span class='line'>1859</span>     * Using the Greek layout when you press v on an US keyboard you get the 
<span class='line'>1860</span>     output character ω. The keyup/keydown events hold keyCode 86 which is V.  
<span class='line'>1861</span>     This does make sense, since it's the virtual key code we are dealing with 
<span class='line'>1862</span>     - not the character code, not the result of pressing the key. The keypress 
<span class='line'>1863</span>     event will hold keyCode 969 (ω).
<span class='line'>1864</span> 
<span class='line'>1865</span>     * Pressing NumPad_Minus you get keyCode 109 in keyup/keydown and keyCode 45 
<span class='line'>1866</span>     in keypress. Again, this happens because in keyup/keydown you don't get the 
<span class='line'>1867</span>     character code, you get the key code, as indicated above. For
<span class='line'>1868</span>     your information: String.fromCharCode(109) = 'm' and String.fromCharCode(45) 
<span class='line'>1869</span>     = '-'.
<span class='line'>1870</span> 
<span class='line'>1871</span>     Therefore, we need to map all the codes of several keys, like F1-F12, 
<span class='line'>1872</span>     Escape, Enter, Tab, etc. This map is held by pwlib.dom.keyCodes. It 
<span class='line'>1873</span>     associates, for example, code 112 to F1, or 13 to Enter. This map is used to 
<span class='line'>1874</span>     detect virtual keys in all events.
<span class='line'>1875</span> 
<span class='line'>1876</span>     (This is only the general story, details about browser-specific differences 
<span class='line'>1877</span>     follow below.)
<span class='line'>1878</span> 
<span class='line'>1879</span>     If the code given by the browser doesn't appear in keyCode maps, it's used 
<span class='line'>1880</span>     as is.  The key_ returned is that of String.fromCharCode(keyCode).
<span class='line'>1881</span> 
<span class='line'>1882</span>     In all browsers we consider all events having keyCode &lt;= 32, as being events  
<span class='line'>1883</span>     generated by a virtual key (not a character). As such, the keyCode value is 
<span class='line'>1884</span>     always searched in pwlib.dom.keyCodes.
<span class='line'>1885</span> 
<span class='line'>1886</span>     As you might notice from the above description, in the keypress event we 
<span class='line'>1887</span>     cannot tell the difference from say F1 and p, because both give the code 
<span class='line'>1888</span>     112. In Gecko and Webkit we can tell the difference because these UAs also 
<span class='line'>1889</span>     set the charCode event property when the key generates a character. If F1 is 
<span class='line'>1890</span>     pressed, or some other virtual key, charCode is never set.
<span class='line'>1891</span> 
<span class='line'>1892</span>     In Opera the charCode property is never set. However, the 'which' event 
<span class='line'>1893</span>     property is not set for several virtual keys. This means we can tell the 
<span class='line'>1894</span>     difference between a character and a virtual key. However, there's a catch: 
<span class='line'>1895</span>     not *all* virtual keys have the 'which' property unset. Known exceptions: 
<span class='line'>1896</span>     Backspace (8), Tab (9), Enter (13), Shift (16), Control (17), Alt (18), 
<span class='line'>1897</span>     Pause (19), Escape (27), End (35), Home (36), Insert (45), Delete (46) and 
<span class='line'>1898</span>     NumLock (144). Given we already consider any keyCode &lt;= 32 being one of some 
<span class='line'>1899</span>     virtual key, fewer exceptions remain. We only have the End, Home, Insert, 
<span class='line'>1900</span>     Delete and the NumLock keys which cannot be 100% properly detected in the 
<span class='line'>1901</span>     keypress event, in Opera. To properly detect End/Home we can check if the 
<span class='line'>1902</span>     Shift modifier is active or not. If the user wants # instead of End, then 
<span class='line'>1903</span>     Shift must be active. The same goes for $ and Home. Thus we now only have 
<span class='line'>1904</span>     the '-' (Insert) and the '.' (Delete) characters incorrectly detected as 
<span class='line'>1905</span>     being Insert/Delete.
<span class='line'>1906</span>     
<span class='line'>1907</span>     The above brings us to one of the main visible difference, when comparing 
<span class='line'>1908</span>     the pwlib.dom.KeyboardEventListener class and the simple 
<span class='line'>1909</span>     pwlib.dom.KeyboardEvent.getKey() function. In getKey(), for the keypress 
<span class='line'>1910</span>     event we cannot accurately determine the exact key, because it requires
<span class='line'>1911</span>     checking the keyCode used for the keydown event. The KeyboardEventListener
<span class='line'>1912</span>     class monitors all the keyboard events, ensuring a more accurate key 
<span class='line'>1913</span>     detection.
<span class='line'>1914</span> 
<span class='line'>1915</span>     Different keyboard layouts and international characters are generally 
<span class='line'>1916</span>     supported. Tested and known to work with the Cyrillic alphabet (Greek 
<span class='line'>1917</span>     keyboard layout) and with the US Dvorak keyboard layouts.
<span class='line'>1918</span> 
<span class='line'>1919</span>     Opera does not fire the keyup event for international characters when 
<span class='line'>1920</span>     running on Linux. For example, this happens with the Greek keyboard layout, 
<span class='line'>1921</span>     when trying Cyrillic characters.
<span class='line'>1922</span> 
<span class='line'>1923</span>     Gecko gives no keyCode/charCode/which for international characters when 
<span class='line'>1924</span>     running on Linux, in the keyup/keydown events. Thus, all such keys remain 
<span class='line'>1925</span>     unidentified for these two events. For the keypress event there are no 
<span class='line'>1926</span>     issues with such characters.
<span class='line'>1927</span> 
<span class='line'>1928</span>     Webkit and Konqueror 4 also implement the keyIdentifier property from the 
<span class='line'>1929</span>     DOM 3 Events specification. In theory, this should be great, but it's not 
<span class='line'>1930</span>     without problems.  Sometimes keyCode/charCode/which are all 0, but 
<span class='line'>1931</span>     keyIdentifier is properly set. For several virtual keys the keyIdentifier 
<span class='line'>1932</span>     value is simply 'U+0000'. Thus, the keyIdentifier is used only if the value 
<span class='line'>1933</span>     is not 'Unidentified' / 'U+0000', and only when keyCode/charCode/which are 
<span class='line'>1934</span>     not available.
<span class='line'>1935</span> 
<span class='line'>1936</span>     Konqueror 4 does not use the 'U+XXXX' notation for Unicode characters. It 
<span class='line'>1937</span>     simply gives the character, directly.
<span class='line'>1938</span> 
<span class='line'>1939</span>     Additionally, Konqueror seems to have some problems with several keyCodes in 
<span class='line'>1940</span>     keydown/keyup. For example, the key '[' gives keyCode 91 instead of 219.  
<span class='line'>1941</span>     Thus, it effectively gives the Unicode for the character, not the key code.  
<span class='line'>1942</span>     This issue is visible with other key as well.
<span class='line'>1943</span> 
<span class='line'>1944</span>     NumPad_Clear is unidentified on Linux in all browsers, but it works on 
<span class='line'>1945</span>     Windows.
<span class='line'>1946</span> 
<span class='line'>1947</span>     In MSIE the keypress event is only fired for characters and for Escape, 
<span class='line'>1948</span>     Space and Enter. Similarly, Webkit only fires the keypress event for 
<span class='line'>1949</span>     characters. However, Webkit does not fire keypress for Escape.
<span class='line'>1950</span> 
<span class='line'>1951</span>     International characters and different keyboard layouts seem to work fine in 
<span class='line'>1952</span>     MSIE as well.
<span class='line'>1953</span> 
<span class='line'>1954</span>     As of MSIE 4.0, the keypress event fires for the following keys:
<span class='line'>1955</span>       * Letters: A - Z (uppercase and lowercase)
<span class='line'>1956</span>       * Numerals: 0 - 9
<span class='line'>1957</span>       * Symbols: ! @ # $ % ^ & * ( ) _ - + = &lt; [ ] { } , . / ? \ | ' ` " ~
<span class='line'>1958</span>       * System: Escape (27), Space (32), Enter (13)
<span class='line'>1959</span> 
<span class='line'>1960</span>     Documentation about the keypress event:
<span class='line'>1961</span>     http://msdn.microsoft.com/en-us/library/ms536939(VS.85).aspx
<span class='line'>1962</span> 
<span class='line'>1963</span>     As of MSIE 4.0, the keydown event fires for the following keys:
<span class='line'>1964</span>       * Editing: Delete (46), Insert (45)
<span class='line'>1965</span>       * Function: F1 - F12
<span class='line'>1966</span>       * Letters: A - Z (uppercase and lowercase)
<span class='line'>1967</span>       * Navigation: Home, End, Left, Right, Up, Down
<span class='line'>1968</span>       * Numerals: 0 - 9
<span class='line'>1969</span>       * Symbols: ! @ # $ % ^ & * ( ) _ - + = &lt; [ ] { } , . / ? \ | ' ` " ~
<span class='line'>1970</span>       * System: Escape (27), Space (32), Shift (16), Tab (9)
<span class='line'>1971</span> 
<span class='line'>1972</span>     As of MSIE 5, the event also fires for the following keys:
<span class='line'>1973</span>       * Editing: Backspace (8)
<span class='line'>1974</span>       * Navigation: PageUp (33), PageDown (34)
<span class='line'>1975</span>       * System: Shift+Tab (9)
<span class='line'>1976</span> 
<span class='line'>1977</span>     Documentation about the keydown event:
<span class='line'>1978</span>     http://msdn.microsoft.com/en-us/library/ms536938(VS.85).aspx
<span class='line'>1979</span> 
<span class='line'>1980</span>     As of MSIE 4.0, the keyup event fires for the following keys:
<span class='line'>1981</span>       * Editing: Delete, Insert
<span class='line'>1982</span>       * Function: F1 - F12
<span class='line'>1983</span>       * Letters: A - Z (uppercase and lowercase)
<span class='line'>1984</span>       * Navigation: Home (36), End (35), Left (37), Right (39), Up (38), Down (40)
<span class='line'>1985</span>       * Numerals: 0 - 9
<span class='line'>1986</span>       * Symbols: ! @ # $ % ^ & * ( ) _ - + = &lt; [ ] { } , . / ? \ | ' ` " ~
<span class='line'>1987</span>       * System: Escape (27), Space (32), Shift (16), Tab (9)
<span class='line'>1988</span> 
<span class='line'>1989</span>     As of MSIE 5, the event also fires for the following keys:
<span class='line'>1990</span>       * Editing: Backspace (8)
<span class='line'>1991</span>       * Navigation: PageUp (33), PageDown (34)
<span class='line'>1992</span>       * System: Shift+Tab (9)
<span class='line'>1993</span> 
<span class='line'>1994</span>     Documentation about the keyup event:
<span class='line'>1995</span>     http://msdn.microsoft.com/en-us/library/ms536940(VS.85).aspx
<span class='line'>1996</span> 
<span class='line'>1997</span>     For further gory details and a different implementation see:
<span class='line'>1998</span>     http://code.google.com/p/doctype/source/browse/trunk/goog/events/keycodes.js
<span class='line'>1999</span>     http://code.google.com/p/doctype/source/browse/trunk/goog/events/keyhandler.js
<span class='line'>2000</span> 
<span class='line'>2001</span>     Opera keydown/keyup:
<span class='line'>2002</span>       These events fire for all keys, including for modifiers.
<span class='line'>2003</span>       keyCode is always set.
<span class='line'>2004</span>       charCode is never set.
<span class='line'>2005</span>       which is always set.
<span class='line'>2006</span>       keyIdentifier is always undefined.
<span class='line'>2007</span> 
<span class='line'>2008</span>     Opera keypress:
<span class='line'>2009</span>       This event fires for all keys, except for modifiers themselves.
<span class='line'>2010</span>       keyCode is always set.
<span class='line'>2011</span>       charCode is never set.
<span class='line'>2012</span>       which is set for all characters. which = 0 for several virtual keys.
<span class='line'>2013</span>       which is known to be set for: Backspace (8), Tab (9), Enter (13), Shift 
<span class='line'>2014</span>       (16), Control (17), Alt (18), Pause (19), Escape (27), End (35), Home 
<span class='line'>2015</span>       (36), Insert (45), Delete (46), NumLock (144).
<span class='line'>2016</span>       which is known to be unset for: F1 - F12, PageUp (33), PageDown (34), Left 
<span class='line'>2017</span>       (37), Up (38), Right (39), Down (40).
<span class='line'>2018</span>       keyIdentifier is always undefined.
<span class='line'>2019</span> 
<span class='line'>2020</span>     MSIE keyup/keypress/keydown:
<span class='line'>2021</span>       Event firing conditions are described above.
<span class='line'>2022</span>       keyCode is always set.
<span class='line'>2023</span>       charCode is never set.
<span class='line'>2024</span>       which is never set.
<span class='line'>2025</span>       keyIdentifier is always undefined.
<span class='line'>2026</span> 
<span class='line'>2027</span>     Webkit keydown/keyup:
<span class='line'>2028</span>       These events fires for all keys, including for modifiers.
<span class='line'>2029</span>       keyCode is always set.
<span class='line'>2030</span>       charCode is never set.
<span class='line'>2031</span>       which is always set.
<span class='line'>2032</span>       keyIdentifier is always set.
<span class='line'>2033</span> 
<span class='line'>2034</span>     Webkit keypress:
<span class='line'>2035</span>       This event fires for characters keys, similarly to MSIE (see above info).
<span class='line'>2036</span>       keyCode is always set.
<span class='line'>2037</span>       charCode is always set for all characters.
<span class='line'>2038</span>       which is always set.
<span class='line'>2039</span>       keyIdentifier is null.
<span class='line'>2040</span> 
<span class='line'>2041</span>     Gecko keydown/keyup:
<span class='line'>2042</span>       These events fire for all keys, including for modifiers.
<span class='line'>2043</span>       keyCode is always set.
<span class='line'>2044</span>       charCode is never set.
<span class='line'>2045</span>       which is always set.
<span class='line'>2046</span>       keyIdentifier is always undefined.
<span class='line'>2047</span> 
<span class='line'>2048</span>     Gecko keypress:
<span class='line'>2049</span>       This event fires for all keys, except for modifiers themselves.
<span class='line'>2050</span>       keyCode is only set for virtual keys, not for characters.
<span class='line'>2051</span>       charCode is always set for all characters.
<span class='line'>2052</span>       which is always set for all characters and for the Enter virtual key.
<span class='line'>2053</span>       keyIdentifier is always undefined.
<span class='line'>2054</span> 
<span class='line'>2055</span>     Another important difference between the KeyboardEventListener class and the 
<span class='line'>2056</span>     getKey() function is that the class tries to ensure that the keypress event 
<span class='line'>2057</span>     is fired for the handler, even if the Web browser does not do it natively.  
<span class='line'>2058</span>     Also, the class tries to provide a consistent approach to keyboard event 
<span class='line'>2059</span>     repetition when the user holds down a key for longer periods of time, by 
<span class='line'>2060</span>     repeating only the keypress event.
<span class='line'>2061</span> 
<span class='line'>2062</span>     On Linux, Opera, Firefox and Konqueror do not repeat the keydown event, only 
<span class='line'>2063</span>     keypress. On Windows, Opera, Firefox and MSIE do repeat the keydown and 
<span class='line'>2064</span>     keypress events while the user holds down the key. Webkit  repeats the 
<span class='line'>2065</span>     keydown and the keypress (when it fires) events on both systems.
<span class='line'>2066</span> 
<span class='line'>2067</span>     The default action can be prevented for during keydown in MSIE, and during 
<span class='line'>2068</span>     keypress for the other browsers. In Webkit when keypress doesn't fire, 
<span class='line'>2069</span>     keydown needs to be prevented.
<span class='line'>2070</span> 
<span class='line'>2071</span>     The KeyboardEventListener class tries to bring consistency. The keydown 
<span class='line'>2072</span>     event never repeats, only the keypress event repeats and it always fires for 
<span class='line'>2073</span>     all keys. The keypress event never fires for modifiers. Events should always 
<span class='line'>2074</span>     be prevented during keypress - the class deals with preventing the event 
<span class='line'>2075</span>     during keydown or keypress as needed in Webkit and MSIE.
<span class='line'>2076</span> 
<span class='line'>2077</span>     If no code/keyIdentifier is given by the browser, the getKey() function 
<span class='line'>2078</span>     returns null. In the case of the KeyboardEventListener class, keyCode_ 
<span class='line'>2079</span>     / key_ / charCode_ / char_ will be null or undefined.
<span class='line'>2080</span>    */</span><span class="WHIT">
<span class='line'>2081</span> 
<span class='line'>2082</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2083</span>    * During a keyboard event flow, this holds the current key code, starting 
<span class='line'>2084</span>    * from the &lt;code>keydown&lt;/code> event.
<span class='line'>2085</span>    *
<span class='line'>2086</span>    * @private
<span class='line'>2087</span>    * @type Number
<span class='line'>2088</span>    */</span><span class="WHIT">
<span class='line'>2089</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2090</span> 
<span class='line'>2091</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2092</span>    * During a keyboard event flow, this holds the current key, starting from the 
<span class='line'>2093</span>    * &lt;code>keydown&lt;/code> event.
<span class='line'>2094</span>    *
<span class='line'>2095</span>    * @private
<span class='line'>2096</span>    * @type String
<span class='line'>2097</span>    */</span><span class="WHIT">
<span class='line'>2098</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2099</span> 
<span class='line'>2100</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2101</span>    * During a keyboard event flow, this holds the current character code, 
<span class='line'>2102</span>    * starting from the &lt;code>keypress&lt;/code> event.
<span class='line'>2103</span>    *
<span class='line'>2104</span>    * @private
<span class='line'>2105</span>    * @type Number
<span class='line'>2106</span>    */</span><span class="WHIT">
<span class='line'>2107</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2108</span> 
<span class='line'>2109</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2110</span>    * During a keyboard event flow, this holds the current character, starting 
<span class='line'>2111</span>    * from the &lt;code>keypress&lt;/code> event.
<span class='line'>2112</span>    *
<span class='line'>2113</span>    * @private
<span class='line'>2114</span>    * @type String
<span class='line'>2115</span>    */</span><span class="WHIT">
<span class='line'>2116</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2117</span> 
<span class='line'>2118</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2119</span>    * True if the current keyboard event is repeating. This happens when the user 
<span class='line'>2120</span>    * holds down a key for longer periods of time.
<span class='line'>2121</span>    *
<span class='line'>2122</span>    * @private
<span class='line'>2123</span>    * @type Boolean
<span class='line'>2124</span>    */</span><span class="WHIT">
<span class='line'>2125</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">repeat_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2126</span> 
<span class='line'>2127</span> 
<span class='line'>2128</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">handlers_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2129</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be of type an object.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2130</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2131</span> 
<span class='line'>2132</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">handlers_.keydown</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">handlers_.keypress</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">handlers_.keyup</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2133</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The provided handlers object has no keyboard event'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>2134</span> </span><span class="WHIT">        </span><span class="STRN">'handler.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2135</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2136</span> 
<span class='line'>2137</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">handlers_.keydown</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">handlers_.keydown</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2138</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The keydown event handler is not a function!'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2139</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2140</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">handlers_.keypress</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">handlers_.keypress</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2141</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The keypress event handler is not a function!'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2142</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2143</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">handlers_.keyup</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">handlers_.keyup</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2144</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The keyup event handler is not a function!'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2145</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2146</span> 
<span class='line'>2147</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2148</span>    * Attach the keyboard event listeners to the current DOM element.
<span class='line'>2149</span>    */</span><span class="WHIT">
<span class='line'>2150</span> </span><span class="WHIT">  </span><span class="NAME">this.attach</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2151</span> </span><span class="WHIT">    </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2152</span> </span><span class="WHIT">    </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2153</span> </span><span class="WHIT">    </span><span class="NAME">charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2154</span> </span><span class="WHIT">    </span><span class="NAME">char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2155</span> </span><span class="WHIT">    </span><span class="NAME">repeat_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2156</span> 
<span class='line'>2157</span> </span><span class="WHIT">    </span><span class="COMM">// FIXME: I have some ideas for a solution to the problem of having multiple </span><span class="WHIT">
<span class='line'>2158</span> </span><span class="WHIT">    </span><span class="COMM">// event handlers like these attached to the same element. Somehow, only one </span><span class="WHIT">
<span class='line'>2159</span> </span><span class="WHIT">    </span><span class="COMM">// should do all the needed work.</span><span class="WHIT">
<span class='line'>2160</span> 
<span class='line'>2161</span> </span><span class="WHIT">    </span><span class="NAME">elem_.addEventListener</span><span class="PUNC">(</span><span class="STRN">'keydown'</span><span class="PUNC">,</span><span class="WHIT">  </span><span class="NAME">keydown</span><span class="PUNC">,</span><span class="WHIT">  </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2162</span> </span><span class="WHIT">    </span><span class="NAME">elem_.addEventListener</span><span class="PUNC">(</span><span class="STRN">'keypress'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">keypress</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2163</span> </span><span class="WHIT">    </span><span class="NAME">elem_.addEventListener</span><span class="PUNC">(</span><span class="STRN">'keyup'</span><span class="PUNC">,</span><span class="WHIT">    </span><span class="NAME">keyup</span><span class="PUNC">,</span><span class="WHIT">    </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2164</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2165</span> 
<span class='line'>2166</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2167</span>    * Detach the keyboard event listeners from the current DOM element.
<span class='line'>2168</span>    */</span><span class="WHIT">
<span class='line'>2169</span> </span><span class="WHIT">  </span><span class="NAME">this.detach</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2170</span> </span><span class="WHIT">    </span><span class="NAME">elem_.removeEventListener</span><span class="PUNC">(</span><span class="STRN">'keydown'</span><span class="PUNC">,</span><span class="WHIT">  </span><span class="NAME">keydown</span><span class="PUNC">,</span><span class="WHIT">  </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2171</span> </span><span class="WHIT">    </span><span class="NAME">elem_.removeEventListener</span><span class="PUNC">(</span><span class="STRN">'keypress'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">keypress</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2172</span> </span><span class="WHIT">    </span><span class="NAME">elem_.removeEventListener</span><span class="PUNC">(</span><span class="STRN">'keyup'</span><span class="PUNC">,</span><span class="WHIT">    </span><span class="NAME">keyup</span><span class="PUNC">,</span><span class="WHIT">    </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2173</span> 
<span class='line'>2174</span> </span><span class="WHIT">    </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2175</span> </span><span class="WHIT">    </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2176</span> </span><span class="WHIT">    </span><span class="NAME">charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2177</span> </span><span class="WHIT">    </span><span class="NAME">char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2178</span> </span><span class="WHIT">    </span><span class="NAME">repeat_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2179</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2180</span> 
<span class='line'>2181</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2182</span>    * Dispatch an event.
<span class='line'>2183</span>    *
<span class='line'>2184</span>    * &lt;p>This function simply invokes the handler for the event of the given 
<span class='line'>2185</span>    * &lt;var>type&lt;/var>. The handler receives the &lt;var>ev&lt;/var> event.
<span class='line'>2186</span>    *
<span class='line'>2187</span>    * @private
<span class='line'>2188</span>    * @param {String} type The event type to dispatch.
<span class='line'>2189</span>    * @param {Event} ev The DOM Event object to dispatch to the handler.
<span class='line'>2190</span>    */</span><span class="WHIT">
<span class='line'>2191</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">dispatch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ev</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2192</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">handlers_</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2193</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2194</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2195</span> 
<span class='line'>2196</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">handler</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">handlers_</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2197</span> 
<span class='line'>2198</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">ev.type</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2199</span> </span><span class="WHIT">      </span><span class="NAME">handler.call</span><span class="PUNC">(</span><span class="NAME">elem_</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ev</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2200</span> 
<span class='line'>2201</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2202</span> </span><span class="WHIT">      </span><span class="COMM">// This happens when the keydown event tries to dispatch a keypress event.</span><span class="WHIT">
<span class='line'>2203</span> 
<span class='line'>2204</span> </span><span class="WHIT">      </span><span class="COMM">// FIXME: I could use createEvent() ... food for thought for later.</span><span class="WHIT">
<span class='line'>2205</span> 
<span class='line'>2206</span> </span><span class="WHIT">      </span><span class="COMM">/** @ignore */</span><span class="WHIT">
<span class='line'>2207</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ev_new</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2208</span> </span><span class="WHIT">      </span><span class="NAME">pwlib.extend</span><span class="PUNC">(</span><span class="NAME">ev_new</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ev</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2209</span> </span><span class="WHIT">      </span><span class="NAME">ev_new.type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2210</span> 
<span class='line'>2211</span> </span><span class="WHIT">      </span><span class="COMM">// Make sure preventDefault() is not borked...</span><span class="WHIT">
<span class='line'>2212</span> </span><span class="WHIT">      </span><span class="COMM">/** @ignore */</span><span class="WHIT">
<span class='line'>2213</span> </span><span class="WHIT">      </span><span class="NAME">ev_new.preventDefault</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2214</span> </span><span class="WHIT">        </span><span class="NAME">ev.preventDefault</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2215</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2216</span> 
<span class='line'>2217</span> </span><span class="WHIT">      </span><span class="NAME">handler.call</span><span class="PUNC">(</span><span class="NAME">elem_</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ev_new</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2218</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2219</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2220</span> 
<span class='line'>2221</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2222</span>    * The &lt;code>keydown&lt;/code> event handler. This function determines the key 
<span class='line'>2223</span>    * pressed by the user, and checks if the &lt;code>keypress&lt;/code> event will 
<span class='line'>2224</span>    * fire in the current Web browser, or not. If it does not, a synthetic 
<span class='line'>2225</span>    * &lt;code>keypress&lt;/code> event will be fired.
<span class='line'>2226</span>    *
<span class='line'>2227</span>    * @private
<span class='line'>2228</span>    * @param {Event} ev The DOM Event object.
<span class='line'>2229</span>    */</span><span class="WHIT">
<span class='line'>2230</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">keydown</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2231</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">prevKey</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2232</span> 
<span class='line'>2233</span> </span><span class="WHIT">    </span><span class="NAME">charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2234</span> </span><span class="WHIT">    </span><span class="NAME">char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2235</span> 
<span class='line'>2236</span> </span><span class="WHIT">    </span><span class="NAME">findKeyCode</span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2237</span> 
<span class='line'>2238</span> </span><span class="WHIT">    </span><span class="NAME">ev.keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">keyCode_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2239</span> </span><span class="WHIT">    </span><span class="NAME">ev.key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2240</span> </span><span class="WHIT">    </span><span class="NAME">ev.repeat_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">prevKey</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2241</span> 
<span class='line'>2242</span> </span><span class="WHIT">    </span><span class="NAME">repeat_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ev.repeat_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2243</span> 
<span class='line'>2244</span> </span><span class="WHIT">    </span><span class="COMM">// When the user holds down a key for a longer period of time, the keypress </span><span class="WHIT">
<span class='line'>2245</span> </span><span class="WHIT">    </span><span class="COMM">// event is generally repeated. However, in Webkit keydown is repeated (and </span><span class="WHIT">
<span class='line'>2246</span> </span><span class="WHIT">    </span><span class="COMM">// keypress if it fires keypress for the key). As such, we do not dispatch </span><span class="WHIT">
<span class='line'>2247</span> </span><span class="WHIT">    </span><span class="COMM">// the keydown event when a key event starts to be repeated.</span><span class="WHIT">
<span class='line'>2248</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">repeat_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2249</span> </span><span class="WHIT">      </span><span class="NAME">dispatch</span><span class="PUNC">(</span><span class="STRN">'keydown'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ev</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2250</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2251</span> 
<span class='line'>2252</span> </span><span class="WHIT">    </span><span class="COMM">// MSIE and Webkit only fire the keypress event for characters </span><span class="WHIT">
<span class='line'>2253</span> </span><span class="WHIT">    </span><span class="COMM">// (alpha-numeric and symbols).</span><span class="WHIT">
<span class='line'>2254</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">isModifierKey</span><span class="PUNC">(</span><span class="NAME">key_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">firesKeyPress</span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2255</span> </span><span class="WHIT">      </span><span class="NAME">ev.type_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'keydown'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2256</span> </span><span class="WHIT">      </span><span class="NAME">keypress</span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2257</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2258</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2259</span> 
<span class='line'>2260</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2261</span>    * The &lt;code>keypress&lt;/code> event handler. This function determines the 
<span class='line'>2262</span>    * character generated by the keyboard event.
<span class='line'>2263</span>    *
<span class='line'>2264</span>    * @private
<span class='line'>2265</span>    * @param {Event} ev The DOM Event object.
<span class='line'>2266</span>    */</span><span class="WHIT">
<span class='line'>2267</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">keypress</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2268</span> </span><span class="WHIT">    </span><span class="COMM">// We reuse the keyCode_/key_ from the keydown event, because ev.keyCode </span><span class="WHIT">
<span class='line'>2269</span> </span><span class="WHIT">    </span><span class="COMM">// generally holds the character code during the keypress event.</span><span class="WHIT">
<span class='line'>2270</span> </span><span class="WHIT">    </span><span class="COMM">// However, if keyCode_ is not available, try to determine the key for this </span><span class="WHIT">
<span class='line'>2271</span> </span><span class="WHIT">    </span><span class="COMM">// event as well.</span><span class="WHIT">
<span class='line'>2272</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">keyCode_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2273</span> </span><span class="WHIT">      </span><span class="NAME">findKeyCode</span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2274</span> </span><span class="WHIT">      </span><span class="NAME">repeat_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2275</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2276</span> 
<span class='line'>2277</span> </span><span class="WHIT">    </span><span class="NAME">ev.keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">keyCode_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2278</span> </span><span class="WHIT">    </span><span class="NAME">ev.key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2279</span> 
<span class='line'>2280</span> </span><span class="WHIT">    </span><span class="NAME">findCharCode</span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2281</span> 
<span class='line'>2282</span> </span><span class="WHIT">    </span><span class="NAME">ev.charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">charCode_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2283</span> </span><span class="WHIT">    </span><span class="NAME">ev.char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">char_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2284</span> 
<span class='line'>2285</span> </span><span class="WHIT">    </span><span class="COMM">// Any subsequent keypress event is considered a repeated keypress (the user </span><span class="WHIT">
<span class='line'>2286</span> </span><span class="WHIT">    </span><span class="COMM">// is holding down the key).</span><span class="WHIT">
<span class='line'>2287</span> </span><span class="WHIT">    </span><span class="NAME">ev.repeat_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">repeat_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2288</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">repeat_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2289</span> </span><span class="WHIT">      </span><span class="NAME">repeat_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2290</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2291</span> 
<span class='line'>2292</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">isModifierKey</span><span class="PUNC">(</span><span class="NAME">key_</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2293</span> </span><span class="WHIT">      </span><span class="NAME">dispatch</span><span class="PUNC">(</span><span class="STRN">'keypress'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ev</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2294</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2295</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2296</span> 
<span class='line'>2297</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2298</span>    * The &lt;code>keyup&lt;/code> event handler.
<span class='line'>2299</span>    *
<span class='line'>2300</span>    * @private
<span class='line'>2301</span>    * @param {Event} ev The DOM Event object.
<span class='line'>2302</span>    */</span><span class="WHIT">
<span class='line'>2303</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">keyup</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2304</span> </span><span class="WHIT">    </span><span class="COMM">/*
<span class='line'>2305</span>      * Try to determine the keyCode_ for keyup again, even if we might already 
<span class='line'>2306</span>      * have it from keydown. This is needed because the user might press some 
<span class='line'>2307</span>      * key which only generates the keydown and keypress events, after which 
<span class='line'>2308</span>      * a sudden keyup event is fired for a completely different key.
<span class='line'>2309</span>      *
<span class='line'>2310</span>      * Example: in Opera press F2 then Escape. It will first generate two 
<span class='line'>2311</span>      * events, keydown and keypress, for the F2 key. When you press Escape to 
<span class='line'>2312</span>      * close the dialog box, the script receives keyup for Escape.
<span class='line'>2313</span>      */</span><span class="WHIT">
<span class='line'>2314</span> </span><span class="WHIT">    </span><span class="NAME">findKeyCode</span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2315</span> 
<span class='line'>2316</span> </span><span class="WHIT">    </span><span class="NAME">ev.keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">keyCode_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2317</span> </span><span class="WHIT">    </span><span class="NAME">ev.key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2318</span> 
<span class='line'>2319</span> </span><span class="WHIT">    </span><span class="COMM">// Provide the character info from the keypress event in keyup as well.</span><span class="WHIT">
<span class='line'>2320</span> </span><span class="WHIT">    </span><span class="NAME">ev.charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">charCode_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2321</span> </span><span class="WHIT">    </span><span class="NAME">ev.char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">char_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2322</span> 
<span class='line'>2323</span> </span><span class="WHIT">    </span><span class="NAME">dispatch</span><span class="PUNC">(</span><span class="STRN">'keyup'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ev</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2324</span> 
<span class='line'>2325</span> </span><span class="WHIT">    </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2326</span> </span><span class="WHIT">    </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2327</span> </span><span class="WHIT">    </span><span class="NAME">charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2328</span> </span><span class="WHIT">    </span><span class="NAME">char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2329</span> </span><span class="WHIT">    </span><span class="NAME">repeat_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2330</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2331</span> 
<span class='line'>2332</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2333</span>    * Tells if the &lt;var>key&lt;/var> is a modifier or not.
<span class='line'>2334</span>    *
<span class='line'>2335</span>    * @private
<span class='line'>2336</span>    * @param {String} key The key name.
<span class='line'>2337</span>    * @returns {Boolean} True if the &lt;var>key&lt;/var> is a modifier, or false if 
<span class='line'>2338</span>    * not.
<span class='line'>2339</span>    */</span><span class="WHIT">
<span class='line'>2340</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">isModifierKey</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2341</span> </span><span class="WHIT">    </span><span class="KEYW">switch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2342</span> </span><span class="WHIT">      </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'Shift'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>2343</span> </span><span class="WHIT">      </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'Control'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>2344</span> </span><span class="WHIT">      </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'Alt'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>2345</span> </span><span class="WHIT">      </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'Meta'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>2346</span> </span><span class="WHIT">      </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'Win'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>2347</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2348</span> </span><span class="WHIT">      </span><span class="KEYW">default</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>2349</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2350</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2351</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2352</span> 
<span class='line'>2353</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2354</span>    * Tells if the current Web browser will fire the &lt;code>keypress&lt;/code> event 
<span class='line'>2355</span>    * for the current &lt;code>keydown&lt;/code> event object.
<span class='line'>2356</span>    *
<span class='line'>2357</span>    * @private
<span class='line'>2358</span>    * @param {Event} ev The DOM Event object.
<span class='line'>2359</span>    * @returns {Boolean} True if the Web browser will fire 
<span class='line'>2360</span>    * a &lt;code>keypress&lt;/code> event, or false if not.
<span class='line'>2361</span>    */</span><span class="WHIT">
<span class='line'>2362</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">firesKeyPress</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2363</span> </span><span class="WHIT">    </span><span class="COMM">// Gecko does not fire keypress for the Up/Down arrows when the target is an </span><span class="WHIT">
<span class='line'>2364</span> </span><span class="WHIT">    </span><span class="COMM">// input element.</span><span class="WHIT">
<span class='line'>2365</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'Up'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'Down'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">pwlib.browser.gecko</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">ev.target</span><span class="WHIT"> 
<span class='line'>2366</span>         </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">ev.target.tagName.toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'input'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2367</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2368</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2369</span> 
<span class='line'>2370</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">pwlib.browser.msie</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">pwlib.browser.webkit</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2371</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2372</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2373</span> 
<span class='line'>2374</span> </span><span class="WHIT">    </span><span class="COMM">// Check if the key is a character key, or not.</span><span class="WHIT">
<span class='line'>2375</span> </span><span class="WHIT">    </span><span class="COMM">// If it's not a character, then keypress will not fire.</span><span class="WHIT">
<span class='line'>2376</span> </span><span class="WHIT">    </span><span class="COMM">// Known exceptions: keypress fires for Space, Enter and Escape in MSIE.</span><span class="WHIT">
<span class='line'>2377</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'Space'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'Enter'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'Escape'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> 
<span class='line'>2378</span>         </span><span class="NAME">key_.length</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2379</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2380</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2381</span> 
<span class='line'>2382</span> </span><span class="WHIT">    </span><span class="COMM">// Webkit doesn't fire keypress for Escape as well ...</span><span class="WHIT">
<span class='line'>2383</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pwlib.browser.webkit</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'Escape'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2384</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2385</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2386</span> 
<span class='line'>2387</span> </span><span class="WHIT">    </span><span class="COMM">// MSIE does not fire keypress if you hold Control / Alt down, while Shift </span><span class="WHIT">
<span class='line'>2388</span> </span><span class="WHIT">    </span><span class="COMM">// is off. Albeit, based on testing I am not completely sure if Shift needs </span><span class="WHIT">
<span class='line'>2389</span> </span><span class="WHIT">    </span><span class="COMM">// to be down or not. Sometimes MSIE won't fire keypress even if I hold </span><span class="WHIT">
<span class='line'>2390</span> </span><span class="WHIT">    </span><span class="COMM">// Shift down, and sometimes it does. Eh.</span><span class="WHIT">
<span class='line'>2391</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pwlib.browser.msie</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">ev.shiftKey</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev.ctrlKey</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">ev.altKey</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2392</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2393</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2394</span> 
<span class='line'>2395</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2396</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2397</span> 
<span class='line'>2398</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2399</span>    * Determine the key and the key code for the current DOM Event object. This 
<span class='line'>2400</span>    * function updates the &lt;var>keyCode_&lt;/var> and the &lt;var>key_&lt;/var> variables 
<span class='line'>2401</span>    * to hold the result.
<span class='line'>2402</span>    *
<span class='line'>2403</span>    * @private
<span class='line'>2404</span>    * @param {Event} ev The DOM Event object.
<span class='line'>2405</span>    */</span><span class="WHIT">
<span class='line'>2406</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">findKeyCode</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2407</span> </span><span class="WHIT">    </span><span class="COMM">/*
<span class='line'>2408</span>      * If the event has no keyCode/which/keyIdentifier values, then simply do 
<span class='line'>2409</span>      * not overwrite any existing keyCode_/key_.
<span class='line'>2410</span>      */</span><span class="WHIT">
<span class='line'>2411</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev.type</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'keyup'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">ev.keyCode</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">ev.which</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">ev.keyIdentifier</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> 
<span class='line'>2412</span>           </span><span class="NAME">ev.keyIdentifier</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'Unidentified'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">ev.keyIdentifier</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'U+0000'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2413</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2414</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2415</span> 
<span class='line'>2416</span> </span><span class="WHIT">    </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2417</span> </span><span class="WHIT">    </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2418</span> 
<span class='line'>2419</span> </span><span class="WHIT">    </span><span class="COMM">// Try to use keyCode/which.</span><span class="WHIT">
<span class='line'>2420</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev.keyCode</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">ev.which</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2421</span> </span><span class="WHIT">      </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ev.keyCode</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">ev.which</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2422</span> 
<span class='line'>2423</span> </span><span class="WHIT">      </span><span class="COMM">// Fix Webkit quirks</span><span class="WHIT">
<span class='line'>2424</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pwlib.browser.webkit</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2425</span> </span><span class="WHIT">        </span><span class="COMM">// Old Webkit gives keyCode 25 when Shift+Tab is used.</span><span class="WHIT">
<span class='line'>2426</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">25</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">this.shiftKey</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2427</span> </span><span class="WHIT">          </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.Tab</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2428</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">>=</span><span class="WHIT"> </span><span class="NUMB">63232</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyCodes_Safari2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2429</span> </span><span class="WHIT">          </span><span class="COMM">// Old Webkit gives wrong values for several keys.</span><span class="WHIT">
<span class='line'>2430</span> </span><span class="WHIT">          </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyCodes_Safari2</span><span class="PUNC">[</span><span class="NAME">keyCode_</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2431</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2432</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2433</span> 
<span class='line'>2434</span> </span><span class="WHIT">      </span><span class="COMM">// Fix keyCode quirks in all browsers.</span><span class="WHIT">
<span class='line'>2435</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyCodes_fixes</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2436</span> </span><span class="WHIT">        </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyCodes_fixes</span><span class="PUNC">[</span><span class="NAME">keyCode_</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2437</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2438</span> 
<span class='line'>2439</span> </span><span class="WHIT">      </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyCodes</span><span class="PUNC">[</span><span class="NAME">keyCode_</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">String.fromCharCode</span><span class="PUNC">(</span><span class="NAME">keyCode_</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2440</span> 
<span class='line'>2441</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2442</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2443</span> 
<span class='line'>2444</span> </span><span class="WHIT">    </span><span class="COMM">// Try to use ev.keyIdentifier. This is only available in Webkit and </span><span class="WHIT">
<span class='line'>2445</span> </span><span class="WHIT">    </span><span class="COMM">// Konqueror 4, each having some quirks. Sometimes the property is needed, </span><span class="WHIT">
<span class='line'>2446</span> </span><span class="WHIT">    </span><span class="COMM">// because keyCode/which are not always available.</span><span class="WHIT">
<span class='line'>2447</span> 
<span class='line'>2448</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2449</span> </span><span class="WHIT">        </span><span class="NAME">keyCode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2450</span> </span><span class="WHIT">        </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ev.keyIdentifier</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2451</span> 
<span class='line'>2452</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'Unidentified'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'U+0000'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2453</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2454</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2455</span> 
<span class='line'>2456</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'U+'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2457</span> </span><span class="WHIT">      </span><span class="COMM">// Webkit gives character codes using the 'U+XXXX' notation, as per spec.</span><span class="WHIT">
<span class='line'>2458</span> </span><span class="WHIT">      </span><span class="NAME">keyCode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">id.substr</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2459</span> 
<span class='line'>2460</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id.length</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2461</span> </span><span class="WHIT">      </span><span class="COMM">// Konqueror 4 implements keyIdentifier, and they provide the Unicode </span><span class="WHIT">
<span class='line'>2462</span> </span><span class="WHIT">      </span><span class="COMM">// character directly, instead of using the 'U+XXXX' notation.</span><span class="WHIT">
<span class='line'>2463</span> </span><span class="WHIT">      </span><span class="NAME">keyCode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id.charCodeAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2464</span> </span><span class="WHIT">      </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2465</span> 
<span class='line'>2466</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2467</span> </span><span class="WHIT">      </span><span class="COMM">/*
<span class='line'>2468</span>        * Common keyIdentifiers like 'PageDown' are used as they are.
<span class='line'>2469</span>        * We determine the common keyCode used by Web browsers, from the 
<span class='line'>2470</span>        * pwlib.dom.keyNames object.
<span class='line'>2471</span>        */</span><span class="WHIT">
<span class='line'>2472</span> </span><span class="WHIT">      </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2473</span> </span><span class="WHIT">      </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2474</span> 
<span class='line'>2475</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2476</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2477</span> 
<span class='line'>2478</span> </span><span class="WHIT">    </span><span class="COMM">// Some keyIdentifiers like 'U+007F' (127: Delete) need to become key names.</span><span class="WHIT">
<span class='line'>2479</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">keyCode</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyCodes</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">keyCode</span><span class="WHIT"> </span><span class="PUNC">&lt;=</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">keyCode</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">127</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> 
<span class='line'>2480</span>           </span><span class="NAME">keyCode</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">144</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2481</span> </span><span class="WHIT">      </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyCodes</span><span class="PUNC">[</span><span class="NAME">keyCode</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2482</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2483</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2484</span> </span><span class="WHIT">        </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">String.fromCharCode</span><span class="PUNC">(</span><span class="NAME">keyCode</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2485</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2486</span> 
<span class='line'>2487</span> </span><span class="WHIT">      </span><span class="COMM">// Konqueror gives lower-case chars</span><span class="WHIT">
<span class='line'>2488</span> </span><span class="WHIT">      </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key.toUpperCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2489</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2490</span> </span><span class="WHIT">        </span><span class="NAME">keyCode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key_.charCodeAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2491</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2492</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2493</span> 
<span class='line'>2494</span> </span><span class="WHIT">    </span><span class="COMM">// Correct the keyCode, make sure it's a common keyCode, not the Unicode </span><span class="WHIT">
<span class='line'>2495</span> </span><span class="WHIT">    </span><span class="COMM">// decimal representation of the character.</span><span class="WHIT">
<span class='line'>2496</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'Delete'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">key_.length</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2497</span> </span><span class="WHIT">      </span><span class="NAME">keyCode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames</span><span class="PUNC">[</span><span class="NAME">key_</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2498</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2499</span> 
<span class='line'>2500</span> </span><span class="WHIT">    </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">keyCode</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2501</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2502</span> 
<span class='line'>2503</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2504</span>    * Determine the character and the character code for the current DOM Event 
<span class='line'>2505</span>    * object. This function updates the &lt;var>charCode_&lt;/var> and the 
<span class='line'>2506</span>    * &lt;var>char_&lt;/var> variables to hold the result.
<span class='line'>2507</span>    *
<span class='line'>2508</span>    * @private
<span class='line'>2509</span>    * @param {Event} ev The DOM Event object.
<span class='line'>2510</span>    */</span><span class="WHIT">
<span class='line'>2511</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">findCharCode</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2512</span> </span><span class="WHIT">    </span><span class="NAME">charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2513</span> </span><span class="WHIT">    </span><span class="NAME">char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2514</span> 
<span class='line'>2515</span> </span><span class="WHIT">    </span><span class="COMM">// Webkit and Gecko implement ev.charCode.</span><span class="WHIT">
<span class='line'>2516</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev.charCode</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2517</span> </span><span class="WHIT">      </span><span class="NAME">charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ev.charCode</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2518</span> </span><span class="WHIT">      </span><span class="NAME">char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">String.fromCharCode</span><span class="PUNC">(</span><span class="NAME">ev.charCode</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2519</span> 
<span class='line'>2520</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2521</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2522</span> 
<span class='line'>2523</span> </span><span class="WHIT">    </span><span class="COMM">// Try the keyCode mess.</span><span class="WHIT">
<span class='line'>2524</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev.keyCode</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">ev.which</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2525</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">keyCode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ev.keyCode</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">ev.which</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2526</span> 
<span class='line'>2527</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">force</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2528</span> 
<span class='line'>2529</span> </span><span class="WHIT">      </span><span class="COMM">// We accept some keyCodes.</span><span class="WHIT">
<span class='line'>2530</span> </span><span class="WHIT">      </span><span class="KEYW">switch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">keyCode</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2531</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.Tab</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>2532</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.Enter</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>2533</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.Space</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>2534</span> </span><span class="WHIT">          </span><span class="NAME">force</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2535</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2536</span> 
<span class='line'>2537</span> </span><span class="WHIT">      </span><span class="COMM">// Do not consider the keyCode a character code, if during the keydown </span><span class="WHIT">
<span class='line'>2538</span> </span><span class="WHIT">      </span><span class="COMM">// event it was determined the key does not generate a character, unless </span><span class="WHIT">
<span class='line'>2539</span> </span><span class="WHIT">      </span><span class="COMM">// it's Tab, Enter or Space.</span><span class="WHIT">
<span class='line'>2540</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">force</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key_.length</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2541</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2542</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2543</span> 
<span class='line'>2544</span> </span><span class="WHIT">      </span><span class="COMM">// If the keypress event at hand is synthetically dispatched by keydown, </span><span class="WHIT">
<span class='line'>2545</span> </span><span class="WHIT">      </span><span class="COMM">// then special treatment is needed. This happens only in Webkit and MSIE.</span><span class="WHIT">
<span class='line'>2546</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev.type_</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'keydown'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2547</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyCodes</span><span class="PUNC">[</span><span class="NAME">keyCode</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2548</span> </span><span class="WHIT">        </span><span class="COMM">// Check if the keyCode points to a single character.</span><span class="WHIT">
<span class='line'>2549</span> </span><span class="WHIT">        </span><span class="COMM">// If it does, use it.</span><span class="WHIT">
<span class='line'>2550</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key.length</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2551</span> </span><span class="WHIT">          </span><span class="NAME">charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key.charCodeAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// keyCodes != charCodes</span><span class="WHIT">
<span class='line'>2552</span> </span><span class="WHIT">          </span><span class="NAME">char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2553</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2554</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">keyCode</span><span class="WHIT"> </span><span class="PUNC">>=</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">force</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2555</span> </span><span class="WHIT">        </span><span class="COMM">// For normal keypress events, we are done.</span><span class="WHIT">
<span class='line'>2556</span> </span><span class="WHIT">        </span><span class="NAME">charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">keyCode</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2557</span> </span><span class="WHIT">        </span><span class="NAME">char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">String.fromCharCode</span><span class="PUNC">(</span><span class="NAME">keyCode</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2558</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2559</span> 
<span class='line'>2560</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">charCode_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2561</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2562</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2563</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2564</span> 
<span class='line'>2565</span> </span><span class="WHIT">    </span><span class="COMM">/*
<span class='line'>2566</span>      * Webkit and Konqueror do not provide a keyIdentifier in the keypress 
<span class='line'>2567</span>      * event, as per spec. However, in the unlikely case when the keyCode is 
<span class='line'>2568</span>      * missing, and the keyIdentifier is available, we use it.
<span class='line'>2569</span>      *
<span class='line'>2570</span>      * This property might be used when a synthetic keypress event is generated 
<span class='line'>2571</span>      * by the keydown event, and keyCode/charCode/which are all not available.
<span class='line'>2572</span>      */</span><span class="WHIT">
<span class='line'>2573</span> 
<span class='line'>2574</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">c</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2575</span> </span><span class="WHIT">        </span><span class="NAME">charCode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2576</span> </span><span class="WHIT">        </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ev.keyIdentifier</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2577</span> 
<span class='line'>2578</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'Unidentified'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'U+0000'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>2579</span> </span><span class="WHIT">        </span><span class="PUNC">(</span><span class="NAME">id.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'U+'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">id.length</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2580</span> 
<span class='line'>2581</span> </span><span class="WHIT">      </span><span class="COMM">// Characters in Konqueror...</span><span class="WHIT">
<span class='line'>2582</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id.length</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2583</span> </span><span class="WHIT">        </span><span class="NAME">charCode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id.charCodeAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2584</span> </span><span class="WHIT">        </span><span class="NAME">c</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2585</span> 
<span class='line'>2586</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2587</span> </span><span class="WHIT">        </span><span class="COMM">// Webkit uses the 'U+XXXX' notation as per spec.</span><span class="WHIT">
<span class='line'>2588</span> </span><span class="WHIT">        </span><span class="NAME">charCode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">id.substr</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2589</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2590</span> 
<span class='line'>2591</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">charCode</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.Tab</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT">
<span class='line'>2592</span> </span><span class="WHIT">          </span><span class="NAME">charCode</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.Enter</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT">
<span class='line'>2593</span> </span><span class="WHIT">          </span><span class="NAME">charCode</span><span class="WHIT"> </span><span class="PUNC">>=</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">charCode</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">127</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>2594</span> </span><span class="WHIT">          </span><span class="NAME">charCode</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">pwlib.dom.keyNames.NumLock</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2595</span> 
<span class='line'>2596</span> </span><span class="WHIT">        </span><span class="NAME">charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">charCode</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2597</span> </span><span class="WHIT">        </span><span class="NAME">char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">c</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">String.fromCharCode</span><span class="PUNC">(</span><span class="NAME">charCode</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2598</span> 
<span class='line'>2599</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2600</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2601</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2602</span> 
<span class='line'>2603</span> </span><span class="WHIT">    </span><span class="COMM">// Try to use the key determined from the previous keydown event, if it </span><span class="WHIT">
<span class='line'>2604</span> </span><span class="WHIT">    </span><span class="COMM">// holds a character.</span><span class="WHIT">
<span class='line'>2605</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key_.length</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2606</span> </span><span class="WHIT">      </span><span class="NAME">charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key_.charCodeAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2607</span> </span><span class="WHIT">      </span><span class="NAME">char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2608</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2609</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2610</span> 
<span class='line'>2611</span> </span><span class="WHIT">  </span><span class="NAME">this.attach</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2612</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2613</span> 
<span class='line'>2614</span> </span><span class="COMM">// Check out the libmacrame project: http://code.google.com/p/libmacrame.</span><span class="WHIT">
<span class='line'>2615</span> 
<span class='line'>2616</span> </span><span class="COMM">// vim:set spell spl=en fo=wan1croqlt tw=80 ts=2 sw=2 sts=2 sta et ai cin fenc=utf-8 ff=unix:</span><span class="WHIT">
<span class='line'>2617</span> 
<span class='line'>2618</span> </span></pre></body></html>